#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y2N0eXBlPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxpb21hbmlwPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkKewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgIGNpbi50aWUoMCk7CiAgICBjb3V0LnRpZSgwKTsKICAgIGxvbmcgbG9uZyBhLGIsbTsKICAgIGNpbj4+YT4+Yj4+bTsKICAgIGxvbmcgbG9uZyByZXM9MTsKICAgIGZvcihsb25nIGxvbmcgaT1hO2k8PWI7aSsrKQogICAgewogICAgIHJlcyo9aSVtOwogICAgfQogICAgLy9jb3V0PDxyZXM8PCJcbiI7CiAgICBjb3V0PDxyZXMlbTsKfQ==