#include <bits/stdc++.h>
#define N 410
#define ll long long
#define ull unsigned long long
//#define mo (ll)((ll)1e9+7)
#define squ(x) ((x)*(x))
#define db double
#define all(x) x.begin(),x.end()
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define rep(i,l,r) for(register int i=l;i<=r;++i)
#define drep(i,r,l)for(register int i=r;i>=l;--i)
#define pb push_back
#define inline inline __attribute__((always_inline))
using namespace std;

inline ll read() {
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
ll mo;
ll dp[N][N];

int fac[N], inv[N], bit[N];
ll Pow(ll a, ll b) {
	ll res = 1;
	a %= mo;
	for (; b; b >>= 1, a = a * a % mo)
		if (b & 1) res = res * a % mo;
	return res;
}
void init_inv(int n) {
	fac[0] = 1;
	rep(i, 1, n)fac[i] = (ll)fac[i - 1] * i % mo;
	inv[n] = Pow(fac[n], mo - 2);
	drep(i, n, 1) inv[i - 1] = (ll)inv[i] * i % mo;
}
ll C(int n, int m) {
	if (n < m)return 0;
	return 1ll * fac[n] * inv[m] % mo * inv[n - m] % mo;
}
int main() {
	int n = read(); mo = read();
	init_inv(n);
	bit[0] = 1; rep(i, 1, 400)bit[i] = bit[i - 1] * 1ll * 2 % mo;
	dp[0][0] = 1;
	rep(i, 0, n)rep(j, 0, i)if (dp[i][j] > 0) {
		rep(k, 1, n - i)(dp[i + k + 1][j + k] += dp[i][j] * 1ll * C(j + k, k) % mo
		                 * bit[k - 1] % mo) %= mo;
	}
	ll ans = 0;
	rep(i, 1, n)(ans += dp[n + 1][i]) %= mo;
	printf("%lld\n", ans);
	return 0;
}