def solve(): L,R,M=map(int,input().split()) if L>M: L=M elif R>M: R=M fact=[1]*(M+1) for i in range(1,M+1): fact[i]=i*fact[i-1]%M prod=[1]*(M+1) for i in range(1,M+1): prod[i]=fact[i]*prod[i-1]%M X=0 for i in range(L,R+1): X+=prod[i] return X%M #================================================== print(solve())