#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
#define REP(i, n) for (Long i = 0; i < (Long)n; i++)
using namespace std;

typedef long long Long;

Long MOD;
const int MX = 401;
Long add(Long a, Long b) {
	return (a + b) % MOD;
}

Long mult(Long a, Long b) {
	return (a * b) % MOD;
}

Long dp[MX][MX][2];
bool used[MX][MX][2];

Long fact[MX];
Long inv[MX];
Long pow2[MX];
Long n;
Long count(Long n, Long cnt, int adding = 0) {
	if (n < cnt) return 0;
	if (n == 0) {
		return cnt == 0;
	}
	Long &ans = dp[n][cnt][adding];
	if (used[n][cnt][adding]) return ans;
	used[n][cnt][adding] = true;
	
	ans = 0;
	for (int c = 1; c <= cnt; c++) {
		if (n - c - adding >= 0) {
			Long cur = count(n - c - adding, cnt - c , 1);
			cur = mult(cur , pow2[c - 1]);
			cur = mult(cur, inv[c]);
			ans = add(ans, cur);
		}
	}
	return ans;
}

Long fastPow(Long a, Long b) { //O(logb)
	Long ans = 1;
	while (b > 0) {
		if (b & 1) { 
			ans = mult(ans , a);
		}
		a = mult(a , a);
		b >>= 1; 
	}
	return ans;
}

Long modInverse(Long a) { //O(log mod) , mod prime , (a , mod) coprimes
	return fastPow(a, MOD - 2);
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> MOD;
	fact[0] = inv[0] = pow2[0] = 1;
	for (int i = 1; i < MX; i++) {
		fact[i] = mult(i, fact[i - 1]);
		inv[i] = modInverse(fact[i]);
		pow2[i] = mult(pow2[i - 1] , 2);
	}
	
	Long ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = add(ans, mult(fact[i], count(n , i)));
	}
	cout << ans << "\n";
	return 0;
}
