#include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; const ll MOD = 1000000007LL; int main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n, m; cin >> n >> m; if (n <= m) { cout << 0 << "\n"; return 0; } ll ans = 1; for (ll i = 1; i <= n; i++) { ans = ans * i % m; } cout << ans << "\n"; return 0; }