Is there some general formula for this? For some prime $p$, and some relatively prime $a$, I found that the number of elements in the set described seems to be $$\frac{p-1}{2^k}$$ where $k$ is maximal so that this value is an integer.
However, I found this by manually searching for the pattern in some code output, and some of my examples don't work. For example, for $p=97$, I found that $\{a^{-1}\mod p,a^{-2}\mod p,a^{-3}\mod p\dots\}$ contains $6$ elements. For $p=43$, I found that the set contains $7$ elements.
Also, I used $a=256$ in these cases.
What's amiss here?