#include <fstream>

using namespace std;

long long result(long long &a, long long &b, long long &c)
{
	long long res = 1;
	for (int i = a; i <= b; i++)
	{
		res *= i % c;
	}
	res %= c;
	return res;
}

int main()
{
	ifstream input("CAU1_16.inp");
	ofstream output("CAU1_16.out");
	long long a, b, c;
	input >> a >> b >> c;
	output << result(a, b, c);

	input.close();
	output.close();
	return 0;
}