#include int main () { long long l = 0LL; long long r = 0LL; int m = 0; int res = 0; long long ans = 0LL; long long fact[1000000] = {}; long long fact_prod[1000000] = {}; res = scanf("%lld", &l); res = scanf("%lld", &r); res = scanf("%d", &m); if (l >= ((long long)m)) { printf("0\n"); return 0; } if (r >= ((long long)m)) { r = (long long)(m-1); } fact[0] = 1LL; for (int i = 1; i < m; i++) { fact[i] = (fact[i-1]*((long long)i))%((long long)m); } fact_prod[0] = 1LL; for (int i = 1; i < m; i++) { fact_prod[i] = (fact_prod[i-1]*fact[i])%((long long)m); } for (int i = (int)l; i <= ((int)r); i++) { ans += fact_prod[i]; } printf("%lld\n", ans%((long long)m)); return 0; }