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