#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n, m; cin >> n >> m; lint res = 1; for (lint i = 1; i <= n; ++i) { res *= i; res %= m; } cout << res << '\n'; }