#include<bits/stdc++.h>
using namespace std;
int main()
{
    ifstream fi("cau1_16.inp");
    ofstream fo("cau1_16.out");
    int64_t n,m,k;
    fi>>n>>m>>k;
    int64_t r=1;
    for(int64_t i=n;i<=m;i++)
    {
        r=r*i;
    }
    fo<<r%k;
}
