#include using namespace std; long long f[1001001]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long L,R; int M; cin >> L >> R >> M; long long tmp = 1; f[0] = 1; for(int i = 1; i <= M; i++) { tmp = tmp*i%M; f[i] = (f[i-1]*tmp)%M; } long long ans = 0; for(long long i = L; i <= min(R,(long long)M); i++) { ans += f[i]; ans %= M; } cout << ans << endl; }