#include #include #include #include #include #include #include #include #include #include using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; int res = 1; for (int i = 1; i <= N; i++) { res = (res * i)%M; } cout << res << endl; }