#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; } }