Prove that the number of $a$ which satisfy:
$$ a^n \equiv a \pmod{b}, $$where $b = pq$, $\quad$$p,q$ primes.
is $[\text{gcd}(n-1,p-1)+1] \cdot [\text{gcd}(n-1,q-1)+1]$
Attempt: Since $p,q$ are coprime, then it is equivalent to find the number of $a$ which satisfy: \begin{align} a^n &\equiv a \pmod{p} \iff a^{n-1} \equiv 1 \pmod{p} \tag{1}\\ a^n &\equiv a \pmod{q} \iff a^{n-1} \equiv 1 \pmod{q}\tag{2} \end{align}
From here, I can't figure out why the number of $a$ which satisfy $(1)$ for example, is $\text{gcd}(n-1,p-1)$ (the $+1$ part in the result must be that you have to count $0$). Any help would be appreciated.
Hint: Suppose that $p \nmid a$. Since $a^{p-1} \equiv 1 \pmod p$, if $a^{n-1} \equiv 1 \pmod p$, then $a^{(n-1)r + (p-1)s} \equiv 1 \pmod p$ for every $r,s \in \mathbb Z$. Take $r,s$ as in Bézout's Thm, so that $a^{\gcd(n-1,p-1)} \equiv 1 \pmod p$. Since $\mathbb Z_p$ is a field, there are exactly $\gcd(n-1,p-1)$ solutions for $a^{n-1} \equiv 1 \pmod p$.