#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { ll l, r, m; cin >> l >> r >> m; vector fact(m + 1, 1); rep(i, m) fact[i + 1] = fact[i] * (i + 1) % m; vector f(m + 1, 1); rep(i, m) f[i + 1] = f[i] * fact[i + 1] % m; ll ans = 0; for (ll x = l; x <= r; ++x) { if (x >= m) break; ans += f[x]; ans %= m; } cout << ans << endl; return 0; }