I would like to show that given that $(n,e)$ is the public key as defined in the RSA encription ($n = pq$ for primes $p,q$) then the number of solutions to the equation $ x^e \equiv x \pmod n$ equals to $(\gcd(e-1,p-1)+1)(\gcd(e-1,q-1)+1)$.
The textbook I am using also has a hint that one could use CRT but I do not see how to combine the solution to $x^{e-1} \equiv 1 \pmod p$ into a solution to the original equation.
Could someone please explain how to prove this identity?