We can use a classic combinatorial tactic called stars and bars. Because it is conventional, we will represent each symbol as $\star$ instead of H
. Consider $m=6$:
$$\star \star \star \star \star \star$$
We can then place bars $\vert$ to represent the edges separating boxes. Say $k=3$. Then for example we can have:
$$\star \vert \star \star \star \vert \star \star$$
This represents the case where there is one star in the first box, three stars in the second box, and two stars in the third box. In general, we can place at most one bar in any gap between two stars. For $m$ stars, there will be $m-1$ gaps, and we will need to choose $k-1$ of them to place bars in if we want to define $k$ boxes. Hence, there are in total ${m-1}\choose{k-1}$ possible arrangements.