// Submit in Luogu by 5ab

#include <iostream>
using namespace std;

const int max_n = 400;
int C[max_n+1][max_n+1] = {}, val[max_n+1] = {}, dp[max_n+1][max_n+1] = {};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, mod, ans = 0;

	cin >> n >> mod;

	C[0][0] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= i; j++)
		{
			C[i][j] = C[i-1][j];
			if (j > 0) C[i][j] = (C[i][j] + C[i-1][j-1]) % mod;
		}
	
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < i; j++)
			val[i] = (val[i] + C[i-1][j]% mod)% mod;
	
	for (int i = 1; i <= n; i++)
	{
		dp[0][i] = val[i];
	//	cerr << "dp[0][" << i << "] = " << dp[0][i] << endl;
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = 2*i+1; j <= n; j++)
		{
			dp[i][j] = 0;
			for (int k = 2*i-1; k + 2 <= j; k++)
				dp[i][j] = (dp[i][j] + (1ll * dp[i-1][k] * val[j-k-1])% mod * C[j-i][j-k-1]% mod)% mod;
			
		//	cerr << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
		}
	}

	for (int i = 0; 2 * i + 1 <= n; i++)
		ans = (ans + dp[i][n]) % mod;
	cout << ans << endl;
	
	return 0;
}