l, r, m = map(int, input().split()) fac = 1 now = 1 for i in range(l): fac *= i + 1 fac %= m now *= fac now %= m ans = 0 for i in range(l, r): if i % m == 0: break ans += now ans %= m fac *= i + 1 fac %= m now *= fac now %= m print(ans)