How do I get the number of words with exactly $n$ letters 'a' and $m$ letters 'b' such that if I cycle shift the letters to the right $k$ times, the word would not change.
For example, let $n = m = 3$, and $k = 4$. All possible words are: "ababab" and "bababa". To demonstrate the shifting, let's show that word "abbbaa" is incorrect: $abbbaa \to aabbba \to aaabbb \to baaabb \to bbaaab$.