import std; void main () { long L, R; int M; readln.read(L, R, M); solve(L, R, M); } void solve (long L, long R, int M) { if (M < L) { writeln(0); return; } long[] factorial = new long[](M+1); factorial[0] = 1 % M; foreach (i; 1..M+1) { factorial[i] = i*factorial[i-1] % M; } long ans = 0; long product = 1; foreach (i; 1..L) { product *= factorial[i]; product %= M; } for (long i = L; i <= min(M, R); i++) { product *= factorial[i]; product %= M; ans += product; ans %= M; } writeln(ans); } void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }