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