#include<cstdio>
#define RI register int
#define CI const int&
const int N=5005;
int n,m,mod,f[N][N][2],ans; // f[x][y] x:sum y:last delta
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
inline int sum(CI x,CI y)
{
	int t=x+y; return t>=mod?t-mod:t;
}
int main()
{
	RI i,j; scanf("%d%d",&n,&mod); m=(n-1)/2;
	for (f[0][0][0]=i=1;i<=m;++i) for (j=0;j<=n;++j)
	{
		f[i][j][1]=f[i-1][j][0];
		if (i<=j) inc(f[i][j][1],f[i][j-i][1]);
		f[i][j][0]=f[i][j][1];
		if (i<=j) inc(f[i][j][0],f[i][j-i][0]);
	}
	if (n&1)
	{
		for (i=1;i<=n;++i) for (j=0;n-i-j*(m+1)>=0;++j)
		inc(ans,f[m][n-i-j*(m+1)][0]);
	} else
	{
		for (i=1;i<=n;++i) for (j=0;n-i-j*(m+1)>=0;++j)
		inc(ans,1LL*f[m][n-i-j*(m+1)][0]*(j+1)%mod);
	}
	return printf("%d",ans),0;
}
