#include using namespace std; int main() { int64_t l, r, m; cin >> l >> r >> m; vector fact(m); fact[0] = 1; for(int64_t i = 1; i < m; i++) fact[i] = (fact[i - 1] * i) % m; int64_t ans = 0; int64_t rui = 1; if(m <= l) { cout << 0 << endl; return 0; } for(int64_t i = 1; i < l; i++) { rui *= fact[i]; rui %= m; } for(int64_t i = l; i <= r; i++) { if(m <= i) break; rui *= fact[i]; rui %= m; ans += rui; ans %= m; } cout << ans << endl; return 0; }