#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; //YOU_ARE _GIVEN_TW O_INTEGE RS_N_AND_ M._YOU R_TASK_ IS_TO_FI ND_TH E_FACT ORIAL_O F_N,_MOD ULO_M. signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; if(n >= m) cout << 0 << endl; else{ int ans = 1; rep(i, 1, n + 1) ans = ans * i % m; cout << ans << endl; } }