Let $k\ge1$ and $m\ge1$ be given integers. For any $i=(i_1,\ldots,i_k)\in\{\pm 1\}^k$, define $f(i)=\#\{1\le j\le k: i_j=i_{j+1}=\cdots=i_{j+m-1}\}$. **Question**: given $0\le l\le k$, for how many $i\in\{\pm 1\}^k$ does $f(i)=l$? Here, for notation simplicity, let $i_{k+1}=i_1,i_{k+2}=i_2,\ldots,i_{k+m-1}=i_{m-1}$. For example, suppose $k=4$ and $m=3$, if $i=(+1,+1,+1,+1)$ or $i=(-1,-1,-1,-1)$, then $f(i)=2$; if $i=(+1,+1,+1,-1)$, then $f(i)=1$. There are two $i$'s such that $f(i)=2$, eight $i$'s such that $f(i)=1$, and six $i$'s such that $f(i)=0$. It would be great to have a general and explicit formula for the number of $i\in\{\pm 1\}^k$ such that $f(i)=l$, and the formula should depend on $m,k,l$. Or some references that could help? Thank you.