#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=5010;
int n,mod,a[maxn],k,dp[maxn],ans;
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(mod);
	k=n/2;
	for (int i=1;i<=k+1;i++) a[i]=i-1;
	for (int i=n,j=2;i>k+1;i--,j++) a[i]=j;
	dp[0]=1;
	for (int i=2;i<=n;i++)
	for (int j=a[i];j<=n;j++) update(dp[j],dp[j-a[i]]);
	for (int i=0;i<=n;i++) update(ans,(ll)(n-i)*dp[i]%mod);
	printf("%d\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/