r=range L,R,M=map(int,input().split()) b=1 for i in r(L): b=(b*pow(i+1,L-i,M))%M if b<1:break a=b for i in r(L+1,R+1): if b<1:break for j in r(1,i+1):b=(b*j)%M a+=b print(a%M)