#include using namespace std; typedef long long ll; typedef pair l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; //YOU_ARE_GIVEN_TWO_INTEGERS //N AND M YOUR TASK IS TO FIND THE FACTORIAL OF N, MODULO M int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; ll now = 1; if(N >= M) { cout << 0 << endl; return 0; } for(ll i = 1; i <= N; i++) { now *= i; now %= M; } cout << now << endl; return 0; }