L,R,M = map(int,input().split()) def calc(N): N = min(N,M) ans = 0 now = 1 tmp = 1 for i in range(1,N + 1): tmp *= i tmp %= M now *= tmp now %= M ans += now ans %= M return ans print((calc(R) - calc(L - 1))%M)