/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner in
= new Scanner
(System.
in); int n, m, k = 1;
n = in.nextInt();
m = in.nextInt();
if ( n >= m)
{
}
else
{
for ( int i = 2; i <= n; i++ )
{
k = ( k * i ) % m;
}
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBuLCBtLCBrID0gMTsKICAgIAluID0gaW4ubmV4dEludCgpOwogICAgCW0gPSBpbi5uZXh0SW50KCk7CiAgICAJaWYgKCBuID49IG0pIAogICAgCXsKICAgICAgICAJU3lzdGVtLm91dC5wcmludCgwKTsKICAgIAl9CiAgICAJZWxzZSAKICAgIAl7CiAgICAJCWZvciAoIGludCBpID0gMjsgaSA8PSBuOyBpKysgKSAKICAgIAkJewogICAgICAgICAgICAJayA9ICggayAqIGkgKSAlIG07CiAgICAgICAgCX0KICAgICAgICAJU3lzdGVtLm91dC5wcmludChrKTsgCiAgICAJfQoJfQp9