#include using namespace std; long long N, M, s = 1; int main() { cin >> N >> M; if (N >= M) { cout << "0" << endl; return 0; } for (int i = 1; i <= N; i++) { s *= i; s %= M; } cout << s << endl; return 0; }