#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int main() { ULL N, M; if (N >= M) cout << 0 << endl; else { ULL ans = 1; for (ULL i = 1; i <= N; i++) ans = ans * i % M; cout << ans << endl; } return 0; }