#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
typedef long long LL;
const int N=5010;
int n,m,f[N];
int mul(int a,int b){return (LL)a*b%m;}
void inc(int&a,int b){a+=b;if(a>=m)a-=m;}
int main(){
	cin>>n>>m;
	f[0]=1;
	ref(i,1,n)
		ref(j,0,n-1)if(f[j])
			if(j+(i+1>>1)<n)inc(f[j+(i+1>>1)],f[j]);
	int ans=0;
	ref(i,0,n-1)inc(ans,f[i]);
	cout<<ans<<endl;
}