#include using namespace std; int main() { int n, m; cin >> n >> m; if (n >= m) cout << 0 << endl; else { long long ans = 1; for (int i = 1; i <= n; i++) ans = ans * i % m; cout << ans << endl; } }