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