l,r,M=map(int,input().split()) l=min(l,M-1) r=min(r,M-1) fa=[1] for i in range(1,M+1): fa+=[fa[-1]*i%M] a=0 s=1 for i in range(l): s*=fa[i] s%=M for i in range(l,r+1): s*=fa[i] s%=M a+=s a%=M print(a)