L,R,M=map(int,input().split()) x=[1] y=[1] res=0 for i in range(1,M): x.append(x[-1]*i%M) for i in range(1,M): y.append(y[-1]*x[i]%M) for i in range(L,min(R+1,M)): res=(res+y[i])%M print(res)