#include constexpr int INF = 2147483647; constexpr long long int INF_LL = 9223372036854775807; constexpr int MOD = 1000000007; using namespace std; typedef long long int ll; typedef unsigned long long int ull; //your task is to find the factorial of n modulo m random_device rnd; int main(int argc, char* argv[]) { int N, M; cin >> N >> M; if (N > M) { cout << 0 << endl; } else { int ans = 1; for (int i = 1; i <= N; i++) { ans *= i; ans %= M; } cout << ans << endl; } }