#include typedef long long ll; int main() { ll n, m; std::cin >> n >> m; ll fact = 1; for (ll i = 1; i <= n; i++) fact *= i; std::cout << fact % m << std::endl; }