""" """ import sys from sys import stdin L,R,M = map(int,stdin.readline().split()) fac = [1] for i in range(M+10): fac.append(fac[-1] * (i+1) % M) for i in range(len(fac)-1): fac[i+1] *= fac[i] fac[i+1] %= M for i in range(len(fac)-1): fac[i+1] += fac[i] fac[i+1] %= M if L >= M: print (0) else: R = min(R , M) ans = fac[R] - fac[L-1] print (ans % M)