#include #include #include using namespace atcoder; using mint = modint; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 2000000000000000005 int main(){ long long L,R,M; cin>>L>>R>>M; mint::set_mod(M); mint cur = 1; mint ans = 0; mint mul = 1; long long cc = L; for(int i=1;i<=M;i++){ cur *= i; mul *= cur; if(cc%M==i){ ans += mul; cc++; if(cc>R)break; } } cout<<(ans).val()<