#include<bits/stdc++.h>

using namespace std; 
typedef long long ll;

const int N = 400 + 5;
int n = 0, m = 0;
int dp[N][N] = {};
int c[N][N] = {}, smc[N] = {};
int ans = 0;

int main(){
	cin >> n >> m;
	dp[0][0] = 1;
	for(int i = 0 ; i <= n + 1 ; i ++) for(int j = 0 ; j <= i ; j ++){
		if(j == 0) c[j][i] = 1;
		else c[j][i] = (c[j - 1][i - 1] + c[j][i - 1]) % m;
		
	}
	for(int i = 0 ; i <= n + 1 ; i ++){
		if(i == 0) smc[i] = 1;
		else smc[i] = (smc[i - 1] * 2) % m;
	}
	for(int i = 1 ; i <= n + 1; i ++)
		for(int j = ceil(i / 2.0) ; j < i ; j ++){
			for(int k = i - j - 1 ; k < i - 1 ; k ++) dp[i][j] = (dp[i][j] + (((1ll * dp[k][j - i + k + 1] * c[i - k - 1][j]) % m) * smc[i - k - 2]) % m) % m;
			if(i == n + 1) ans = (ans + dp[i][j]) % m;
	    }
	cout << ans;
	return 0;
}

