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