#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef set<ll> si;
typedef multiset<ll> msi;
typedef map<ll,ll> mii;
ll dp[401][401];
ll fact[401],ifact[401];
ll bigmod(ll a,ll b,ll mod){//mod should be <32 bit
    ll ans=1;
    while(b>0){
        if(b&1)ans=(ans*a)%mod;
        b=b>>1;
        a=(a*a)%mod;
    }
    return ans;
}
int main()
{
    ll t;
    ll i,j,k;
    ll n,m;
    cin>>n>>m;
    for(i=1,fact[0]=1;i<=400;i++)
        fact[i]=(i*fact[i-1])%m;
    for(i=1,ifact[0]=1;i<=400;i++)
        ifact[i]=(bigmod(i,m-2,m)*ifact[i-1])%m;
    for(i=1;i<=n;i++){
        for(j=1;j<i;j++){
            for(k=1;k<=j;k++){
                dp[i][j]=(dp[i][j]+((((fact[j]*ifact[j-k])%m)*((dp[i-k-1][j-k]*ifact[k])%m))%m)*bigmod(2,k-1,m))%m;
            }
        }
        dp[i][i]=bigmod(2,i-1,m);
    }
    ll res=0;
    for(i=1;i<=n;i++)
        res=(res+dp[n][i])%m;
    cout<<res<<endl;
}
