I'm having some trouble proving the following:
Let $d$ be the smallest positive integer such that $a^d \equiv 1 \pmod m$, for $a \in \mathbb Z$ and $m \in \mathbb N$ and with $\gcd(a,m) = 1$. Prove that, if $a^n \equiv 1 \pmod m$ then $d\mid n$.
The first thing that came to my mind was Euler's theorem but I couldn't conclude anything because I'm not very skilled when it comes to using Euler's totient function. Can someone give me any tips or show me how to solve this?