Here's an example
For $n = 4$ and $k = 1$, there are 8 possible arrangements:
$a\ a\ a\ a$
$a\ a\ a\ b$
$a\ a\ b\ a$
$a\ b\ a\ a$
$b\ a\ a\ a$
$b\ a\ b\ a$
$b\ a\ a\ b$
$b\ a\ b\ a$
with $b$ being the element that can't have more than $k$ consecutive appearances.
I'm not really well-versed in combinatorics, so $2^n$ being the total number of arrangements is the only piece of info I came up with.
Anyway, this is actually a programming challenge from one of those competitive programming sites, but I wanna get a grasp of the math behind the idea before thinking about implementation methods, so I figured I'd ask things here. Also, the input range for both $n$ and $k$ is $[1, 10^6]$ so a dynamic programming approach is the way to go.