Right now I know the way to calculate $a^b \bmod c$ which is in the answer of the following question.
Consider the case where $c$ is much larger than $d$. So, the result of $a^b \bmod c$ will be large compared with the final result.
Is there any way to get the final result without getting directly the result of $a^b \bmod c$ which is large?