#include <bits/stdc++.h>
using namespace std;
ifstream fi ("CAU1_16.inp");
ofstream fo ("CAU1_16.out");
int main()
{
    int a,b,c;
    fi>>a>>b>>c;
    int t=a,tg;
    for(int i=a+1;i<=b;i++)
    {
        t=t*i;
        tg=(t%c);
        t=tg;
    }
    fo<<tg;
}
