How to solve $\displaystyle a^x$ $\displaystyle mod$ $\displaystyle b = c$ for $\displaystyle x$ minimum integer solution.
With known integers $\displaystyle a$,$\displaystyle b$, and $\displaystyle c$.
If $\displaystyle b=1,2,4,p^\alpha,2p^\alpha$ with $\displaystyle \alpha\ge 1$ and $\displaystyle p$ an odd prime, then $\displaystyle b$ has a primitive root $\displaystyle g \mod b$.
If $\displaystyle (a,b)=(c,b)=1$ then $\displaystyle x $ind$\displaystyle _g a\equiv $ ind$\displaystyle _g c \pmod {\phi(b)}$ a linear congruence in $\displaystyle x$.
If $\displaystyle d=($ind$\displaystyle _g a,\phi(b))|$ ind$\displaystyle _g c$ then there are exactly $\displaystyle d$ solutions.
Then start by factoring $\displaystyle b$. If $\displaystyle b$ has a factor $\displaystyle 2^f$ with $\displaystyle f\ge 3$ then solve the equation $\displaystyle \mod 2^f$ first.