#include <fstream>
using namespace std;
ifstream f1("cau1_16.inp");
ofstream f2("cau1_16.out");
long long a,b,c;
long long tinh(long long a,long long b)
{
    long tong = 1;
    for (long n = a; n <= b; n++)
    {
        tong = tong * n;
    }
    return tong;
}
int main()
{
    f1 >> a >> b >> c;
    f2 << tinh(a,b)%c;
    return 0;
}
