// 愚直解 #include #define rep(i, l, n) for (int i = (l); i < (n); i++) using namespace std; using ll = long long; int main(void) { ll l, r, m; cin >> l >> r >> m; ll ans = 0ll; rep(n, l, r + 1) { ll a = 1ll; rep(i, 1, n + 1) { ll b = 1ll; rep(j, 1, i + 1) { b *= j; b %= m; } a *= b; a %= m; } ans += a; ans %= m; } cout << ans << endl; return 0; }