#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 413;

int TC;
int N, INF;

int add(int a, int b)
{
    a += b; if (a >= INF) a -= INF; return a;
}
int mul(int a, int b)
{
    return (ll) a * b % INF;
}
int sub(int a, int b)
{
    a -= b; if (a < 0) a += INF; return a;
}
int pwr(int a, int b)
{
    int res = 1;
    while(b > 0)
    {
        if (b & 1) res = mul(res, a);
        b >>= 1;
        a = mul(a, a);
    }
    return res;
}
int inv(int a)
{
    return pwr(a, INF - 2);
}
int dvd(int a, int b)
{
    return mul(a, inv(b));
}

int dp[MAXN][MAXN];
int ans;

int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N >> INF;
    dp[1][1] = 1; //dp[i][j] = the min size is i, and you have j components.
    FOR(i, 1, N + 1)
    {
        FOR(j, 1, N + 1)
        {
            //here, we only play w/ 0 connected component.
            //make a new component, and connect it to neither.
            dp[i + 1][j + 1] = add(dp[i + 1][j + 1], mul(j + 1, dp[i][j]));

            //here, we only play w/ 1 connected component.
            //add a # to the elft of a component.
            dp[i + 1][j] = add(dp[i + 1][j], mul(j, dp[i][j]));
            //add a # to the right of a component.
            dp[i + 1][j] = add(dp[i + 1][j], mul(j, dp[i][j]));
            //add a # two to the left of a component.
            dp[i + 2][j] = add(dp[i + 2][j], mul(j, dp[i][j]));
            //add a new # two to the right of a component.
            dp[i + 2][j] = add(dp[i + 2][j], mul(j, dp[i][j]));
            //make a new component, and connect it to both.

            //here, we merge 2 connected components.
            //1,1 is not allowed!
            //1,2
            dp[i + 2][j - 1] = add(dp[i + 2][j - 1], mul(j - 1, dp[i][j]));
            //2,1
            dp[i + 2][j - 1] = add(dp[i + 2][j - 1], mul(j - 1, dp[i][j]));
            //2,2
            dp[i + 3][j - 1] = add(dp[i + 3][j - 1], mul(j - 1, dp[i][j]));
        }
    }
    ans = dp[N][1];
    cout << ans << '\n';
}
