#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=5005;
int n,mod;
int dp[maxn][maxn];

int main(){
	scanf("%d%d",&n,&mod);
	dp[0][0]=1;
	rep(i,(n-1)/2)rep(j,n+1){
		int cur=dp[i][j];
		if(!cur)continue;
		rep(k,(n-j)/(i+2)+1){
			int coef=k+1;
			if((n&1)&&(i+1)==(n-1)/2)coef=1;
			dp[i+1][j+k*(i+2)]+=1LL*cur*coef%mod;
			if(dp[i+1][j+k*(i+2)]>=mod)dp[i+1][j+k*(i+2)]-=mod;
		}
	}
	int ans=0;
	rep(i,n+1)rep(j,n-i+1){
		ans+=1LL*dp[(n-1)/2][j]*(n-i-j)%mod;
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}