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