/* Rupinder Singh Khokhar */
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<vi> vii;
typedef vector<vl> vll;


int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());
 vl p2(401);
 vll c(401, vl(401));
 c[0][0] = 1;

 p2[0] = 1;
 
 int t = 1;
 //cin >> t;

 while (t--) {
     int n,m;
     cin>>n>>m;
     for (int i = 1; i <= 400; i++) {
        p2[i] = (2*p2[i-1])%m;
    }
    for (int i = 1; i <= 400; i++) {
        c[i][0]=c[i][i]=1;
        for (int j = 1; j < i; j++) {
            c[i][j] = (c[i-1][j-1] + c[i-1][j])%m;
        }
    }
     vll dp(n+2, vl(n+1));
     dp[0][0]=1;
     for (int i = 1; i <= n+1; i++) {
         for (int j = 1; j < i; j++) {
             for (int k = 1; k <= j && i-k-1>=0 && j-k>=0; k++) {
                dp[i][j] = (dp[i][j] + (((dp[i-k-1][j-k]*c[j][k])%m)*p2[k-1])%m)%m;
             }
         }
     }
     ll ans = 0;
     for (int l = 1; l <= n; l++) {
         ans = (ans + dp[n+1][l])%m;
     }
     cout<<ans<<"\n";
 }

 return 0;
}