#include <iostream>
#include <cctype>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a,b,m;
cin>>a>>b>>m;
long long res=1;
for(long long i=a;i<=b;i++)
{
res*=i%m;
}
//cout<<res<<"\n";
cout<<res%m;
}
/*
long long a,b;
cin>>a>>b;
int u = 0 , p = 0;
int x = sqrt(a)+1;
int y = sqrt(b)+1;
for(int i=2;i<=x;i++)
{
if(a%i==0)u++;
}
for(int i=2;i<=y;i++)
{
if(b%i==0)p++;
}
if(u==0||p==0)
{
cout<<1<<" "<<a*b;
return 0;
}
for(int i=max(a,b);i>=2;i--)
{
if(a%i==0&&b%i==0)
{
cout<<i<<" "<<(a*b)/i;
return 0;
}
}
*/
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y2N0eXBlPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxpb21hbmlwPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgbG9uZyBsb25nIGEsYixtOwogICAgY2luPj5hPj5iPj5tOwogICAgbG9uZyBsb25nIHJlcz0xOwogICAgZm9yKGxvbmcgbG9uZyBpPWE7aTw9YjtpKyspCiAgICB7CiAgICAgcmVzKj1pJW07CiAgICB9CiAgICAvL2NvdXQ8PHJlczw8IlxuIjsKICAgIGNvdXQ8PHJlcyVtOwp9Ci8qCiBsb25nIGxvbmcgYSxiOwogICAgY2luPj5hPj5iOwogICAgaW50IHUgPSAwICwgcCA9IDA7CiAgICBpbnQgeCA9IHNxcnQoYSkrMTsKICAgIGludCB5ID0gc3FydChiKSsxOwogICAgZm9yKGludCBpPTI7aTw9eDtpKyspCiAgICAgewogICAgICBpZihhJWk9PTApdSsrOwogICAgIH0KICAgIGZvcihpbnQgaT0yO2k8PXk7aSsrKQogICAgIHsKICAgICAgaWYoYiVpPT0wKXArKzsKICAgICB9CiAgICBpZih1PT0wfHxwPT0wKQogICAgIHsKICAgICAgY291dDw8MTw8IiAiPDxhKmI7CiAgICAgIHJldHVybiAwOwogICAgIH0KICAgICAgIGZvcihpbnQgaT1tYXgoYSxiKTtpPj0yO2ktLSkKICAgICAgICB7CiAgICAgICAgIGlmKGElaT09MCYmYiVpPT0wKQogICAgICAgICAgICB7CiAgICAgICAgICAgICBjb3V0PDxpPDwiICI8PChhKmIpL2k7CiAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgfQogICAgICAgIH0KKi8K