#include <cstdio>
#include <iostream>

using namespace std;

const int _ = 400 + 7;

int n, mod, F[_], G[_], H[_], fac[_], ifac[_], inv[_];

void pls(int &x, int y) { x = (x + y) % mod; }

int C(int n, int m) { return 1ll * fac[n] * ifac[m] % mod * ifac[n - m] % mod; }

int main() {
  cin >> n >> mod; fac[0] = ifac[0] = inv[1] = 1;
  for (int i = 1; i <= n; ++i) {
    fac[i] = 1ll * fac[i - 1] * i % mod;
    if (i != 1) inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
  }

  for (int i = 1; i <= n; ++i) {
    int coef = 0;
    for (int j = 1; j <= i; ++j) pls(coef, C(i - 1, j - 1));
    G[i] = F[i] = 1ll * coef * ifac[i] % mod;
  }

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    pls(ans, 1ll * G[n - i + 1] * fac[n - i + 1] % mod);
    for (int j = 0; j <= n; ++j) {
      H[j] = 0;
      for (int k = 0; k <= j; ++k) pls(H[j], 1ll * F[k] * G[j - k] % mod);
    }
    for (int j = 0; j <= n; ++j) G[j] = H[j];
  }

  printf("%d\n", ans);
  return 0;
}
