#include using lint = long long; void solve() { lint n, m; std::cin >> n >> m; if (n >= m) { std::cout << 0 << "\n"; } else { lint ans = 1; for (lint i = 1; i <= n; ++i) { (ans *= i) %= m; } std::cout << ans << "\n"; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }