#include "bits/stdc++.h" // #include <ext/rope> // using namespace __gnu_cxx; using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; // template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <typename T> istream& operator >> (istream& in, vector<T>& v) { for (auto &it:v) in >> it; return in; } template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (auto it:v) os << it << " "; return os; } template <typename T1, typename T2> istream& operator >> (istream& in, pair<T1,T2>& p) { in >> p.first >> p.second; return in; } template <typename T1, typename T2> ostream& operator << (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; } template <typename T1, typename T2> void minn(T1& a, T2 b) { a = min(a,b); } template <typename T1, typename T2> void maxx(T1& a, T2 b) { a = max(a,b); } #define int long long // #define double long double #define pb push_back #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sz(v) (int)v.size() #define deb(x) cerr<<#x<<"="<<x<<'\n'; const int mod = 1e9 + 7; const int mod2 = 998244353; const double PI = 3.1415926535897932384626433832795; const int raw_mango_seed = chrono::steady_clock::now().time_since_epoch().count(); mt19937 rng(raw_mango_seed); void solve() { int l,r,m; cin>>l>>r>>m; minn(r,m); vector<int> f(r+1); f[0]=1; int ans=0; for(int i=1;i<=r;i++){ f[i]=(f[i-1]*i)%m; } for(int i=1;i<=r;i++){ f[i]=(f[i-1]*f[i])%m; if(i>=l)ans=(ans+f[i])%m; } cout<<ans; } int32_t main() { cin.tie(0)->sync_with_stdio(0); int tc=1; // cin>>tc; while(tc--){ solve(); } return 0; }