#include <iostream>
#include <fstream>
int n,m,p;
int du;
long long int tich;
using namespace std;
int t3(int m,int n)
{
	tich=1;
	for(int i=m;i<=n;i++)
	{
		tich*=i;
	}
	return tich;
}
int main()
{
	ifstream fi("CAU1_16.inp");
	fi>>m>>n>>p;
	fi.close();
	ofstream fo("CAU1_16.out");
	tich=t3(m,n);
	du=tich%p;
	fo<<du;
	fo.close();
	return 0;	
}

