#include "bits/stdc++.h" using namespace std; void solve() { int n, m; cin >> n >> m; if (n >= m) { cout << 0 << endl; return; } int ans = 1; for (int i = 2; i <= n; i++) { ans *= i; ans %= m; } cout << ans << endl; } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }