Idea: Test each formula at the wrap boundary $rear = M-1$.
The circular queue needs the index to cycle through $0, 1, \dots, M-1, 0, \dots$. The advance rule must add one yet stay inside the range.
Check $(rear + 1) \bmod M$ at the last slot:
\[(M-1+1) \bmod M = M \bmod M = 0\]
It wraps to $0$ as required, and for any interior index it simply adds one. The plain $rear+1$ overflows; $rear=1$ is a reset not an increment; and $(rear \bmod M)+1$ can produce $M$, an invalid index.
\[\boxed{(rear + 1)\ \%\ M}\]