
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

constexpr static int MAXN = 410;

int64_t cnt[MAXN][MAXN];

void solve() {
    int n, mod;
    cin >> n >> mod;

    cnt[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i; j++) {
            cnt[i + 1][j + 1] = (cnt[i + 1][j + 1] + cnt[i][j] * (j + 1)) % mod;
            cnt[i + 1][j] = (cnt[i + 1][j] + cnt[i][j] * 2 * j) % mod;
            cnt[i + 2][j] = (cnt[i + 2][j] + cnt[i][j] * 2 * j) % mod;
            if (j > 1) {
                cnt[i + 2][j - 1] = (cnt[i + 2][j - 1] + cnt[i][j] * 2 * (j - 1)) % mod;
                cnt[i + 3][j - 1] = (cnt[i + 3][j - 1] + cnt[i][j] * (j - 1)) % mod;
            }
        }
    }
    cout << cnt[n][1] << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}
