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