#include
using namespace std;
#define _l (long long int)
const int maxn = 1000009;
int n, mod, sz[maxn];
int modPow(int a, int x) { int s(1); for (; x; x »= 1, a = _l a * a % mod) if (x & 1) s = _l s * a % mod; return s; }
struct modInt { int a, b; modInt() {} modInt(int ao, int bo) { a = ao, b = bo; } modInt(int xo) { a = xo; for (b = 0; a % mod == 0; a /= mod, ++ b); a %= mod; } inline void print() { if (b) puts(“0”); else printf("%d\n", a); } }; inline modInt operator *(const modInt& a, const modInt& b) { return modInt(_l a. a * b. a % mod, a. b + b. b); } inline modInt operator /(const modInt& a, const modInt& b) { return modInt(_l a. a * modPow(b. a, mod - 2) % mod, a. b - b. b); }
modInt fac[maxn], f[maxn];
void pre() { fac[0] = modInt(1); for (int i = 1; i <= n; ++ i) fac[i] = fac[i - 1] * modInt(i); }
inline modInt comb(int n, int m) { return fac[n + m] / fac[n] / fac[m]; }
int main() { #ifndef ONLINE_JUDGE freopen(".in", “r”, stdin); #endif
scanf("%d%d", &n, &mod);
pre();
for (int i = n; i; -- i) {
sz[i] = 1;
f[i] = modInt(1);
if (i * 2 <= n) {
f[i] = f[i] * f[i * 2];
sz[i] += sz[i * 2];
}
if (i * 2 + 1 <= n) {
f[i] = f[i] * f[i * 2 + 1];
f[i] = f[i] * comb(sz[i * 2], sz[i * 2 + 1]);
sz[i] += sz[i * 2 + 1];
}
}
f[1]. print();
}