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IJKMNPQRSTUVWXYZ_ABCDEFGHIJKLNOPQRSTUVWXYZ."; //~ char now = 'A'; //~ for(char c : s) //~ if(isupper(c)) { //~ while(now != c) { //~ cout << now; //~ now = next(now); //~ } //~ now = next(now); //~ } else { //~ cout << c; //~ } //~ cout << '\n'; // YOU_ARE_GIVEN_TWO_INTEGERS_N_AND_M._YOUR_TASK_IS_TO_FIND_THE_FACTORIAL_OF_N,_MODULO_M. using ll = long long; ll n, m; cin >> n >> m; n = min(n, m); ll ans = 1 % m; for(int i = 1; i <= n; i ++) ans = ans * i % m; cout << ans << '\n'; }