def f(l,r,m): r1=1 r2=1 ans=0 if(m<=l):return 0 for i in range(1,l): r1=(r1*i)%m r2=(r2*r1)%m for i in range(l,min(m+1,r+1)): r1=(r1*i)%m r2=(r2*r1)%m ans=(ans+r2)%m return ans l,r,m=map(int,input().split()) print(f(l,r,m))