#include using lint = long long; int main() { /* int cur = 0; char c; while (std::cin >> c) { int j = int(c) - int('A'); if (j < 0 || 26 <= j) { std::cout << c; continue; } while (cur != j) { std::cout << char(cur + 'A'); cur = (cur + 1) % 26; } cur = (cur + 1) % 26; } std::cout << std::endl; Problem Statement: You are given two integers N and M. Your task is to find the factorial of N, modulo M. */ int N, M; std::cin >> N >> M; if (N >= M) { std::cout << 0 << std::endl; } else { lint ans = 1; for (lint i = 1; i <= N; ++i) { ans = (ans * i) % M; } std::cout << ans << std::endl; } return 0; }