#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define ld  long double
  
const int INF = 1e9 + 7;
long long MOD;



const int N = 405;

long long dp[N][N];
long long ncr[N][N];
long long p2[N];

void solve(){
    int n;
    cin >> n >> MOD;
    /*
        Trivial observation : If the number of segments of `x` is k and the sizes are x_1 , x_2 , ... , x_k. 
        Then, the number of ways is X! / (x_1! x_2!... x_k!) 2^(x_1 - 1) 2^(x_2 - 1) .. 
    */
    
    p2[0] = 1LL;
    for(int i = 1; i < N; i++){
        p2[i] = p2[i - 1] * 2LL % MOD; 
    }
    ncr[1][0] = ncr[1][1] = 1;

    for(int i = 2; i < N; i++){
        for(int r = 0; r <= i; r++){
            if(r == 0 || r == i) ncr[i][r] = 1;
            else ncr[i][r] = (ncr[i - 1][r] + ncr[i - 1][r - 1]) % MOD;
        }
    }
    
    dp[1][1] = 1;

    for(int i = 2; i <= n; i++){
        for(int manual = 0; manual <= i; manual++){
            for(int last = 1; last <= min(manual , i); last++){
                if(i - last - 1 >= 0){
                    dp[i][manual] += dp[i - last - 1][manual - last] * ncr[manual][last] % MOD * p2[last - 1] % MOD;
                    dp[i][manual] %= MOD;
                } else{
                    assert(i == last);
                    dp[i][manual] = p2[i - 1];
                }
            }
        }
    }

    long long ans = 0;
    for(int manual = 1; manual <= n; manual++){
        ans += dp[n][manual]; ans %= MOD;
    }
    cout << ans << endl;
}

int main(){
    ios :: sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr);
    int tt = 1;
    #ifdef SIEVE
    construct();
    #endif
    for(int tc = 1; tc <= tt; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
}