Prefix function of string is by definition $\pi: \mathbb A^n \to \mathbb N^n$, where $\mathbb A$ is set of all characters of string (alphabet) and $\mathbb N$ is set of natural numbers. If $s$ is vector $(a_1,\ldots,a_n)$, where $ a_i\in \mathbb A$; $s_k=(a_1,\ldots,a_k)$ then $\pi(s)=(p_1,\ldots,p_n)$ where $p_i$ is length of longest prefix (which is not equal to the whole string) of $s_i$ such that it is also suffix of $s_i$.
Given prefix function of string $\pi(s)=(0,0,1,0,1,1,0,1,0)$ and $card(\mathbb A)=168$.
How many such strings exists?
My assumption is that all these strings must be in form $(a_1,a_2,a_1,a_3,a_1,a_1,a_3,a_1,a_3)$ and answer would be $168*167*166$. Is it correct?