#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; if(ans==0)break; } cout<