#include<bits/stdc++.h>
/*
typedef struct st{
    int l, r;
    int ma;
}stree;
stree arr[6000005];*/
//#include<iostream>
//#include<stdlib.h>
using namespace std;
//int ncount[100005], good[200005], alpha[26];
long long powers[405], a[100005], b[100005], f[405][405], dp[405][405];
//long long grid[1005][1005], table[505][505][12];
//int dp[105][200005], a[105];
int nn, mm, kk;
//char str[100005], mal[100005];
//double dp[100005];
//vector<int> pfac[100005];
//map<char,int> has;
//map<long long,vector<long long> >rem;



int main(int argc, char ** argv){
    
    int n, m, res = 0, flag;
    long long mo;
    //int ma = INT_MIN, mi = INT_MAX;
    int t, u, l, w, h, v, k, r, temp, ind, buf, q, num, ma;
    int c;
    int total;
    long long ans = 0;
    //scanf("%d", &t);
    t = 1;
    //ans = min((long long)100000000, (long long)200000000);
    //cout << ans;
    //char alpha;
    while(t){
        
        t--;
        scanf("%d%lld", &n, &mo);
        powers[0] = 1;
        dp[0][0] = 1;
        for(int i = 1;i < 401;i++){
            dp[i][0] = 1;
            dp[i][i] = 1;
            powers[i] = (powers[i - 1] << 1) % mo;
        }
        
        for(int i = 1;i < 401;i++){
            for(int j = 1;j <= i - 1;j++){
                dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mo;
                //cout << dp[i][j] << " ";
            }
            //cout << endl;
        }
        
        for(int i = 1;i <= n;i++){
            f[i + 1][i] = powers[i - 1];
        }
        
        for(int i = 2;i < n;i++){
            for(int j = 0;j < i;j++){
                for(int k = 1;k + j <= n;k++){
                    f[i + k + 1][j + k] += (f[i][j] * powers[k - 1]) % mo * dp[j + k][k] % mo;
                    f[i + k + 1][j + k] %= mo;
                }
            }
        }
        
        for(int i = 0;i <= n;i++)
            ans += f[n + 1][i];
        
        printf("%lld\n", ans % mo);
        
        
    }
    
    return 0;
}