#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=405;
int n,f[N][N],mod;

signed main(){
	read(n);read(mod);
	f[0][0]=1;
	for(int i=0;i<n;i++) for(int j=0;j<=i;j++){
		f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*(j+1))%mod;
		f[i+1][j]=(f[i+1][j]+f[i][j]*j*2)%mod;
		f[i+2][j]=(f[i+2][j]+f[i][j]*j*2)%mod;
		if(j>=2){
			f[i+2][j-1]=(f[i+2][j-1]+f[i][j]*(j-1)*2)%mod;
			f[i+3][j-1]=(f[i+3][j-1]+f[i][j]*(j-1))%mod;
		}
	}
	write(f[n][1]);
}