#include using namespace std; using ll = long long; int main(void) { ll l, r, m; cin >> l >> r >> m; l = min(l, m - 1); r = min(r, m - 1); ll a = 1, b = 1; for (ll i = 2; i < l; i++) { a *= i; a %= m; b *= a; b %= m; } ll ans = 0; for (ll i = l; i <= r; i++) { a *= i; a %= m; b *= a; b %= m; ans += b; ans %= m; } cout << ans << endl; return 0; }