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