#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 5010;
int n,mod,s,dp[N],a[N];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}

int main(){
	n=read(),mod=read();
	int m=n+1>>1;
	For(i,1,m) a[i]=-1;
	For(i,m+1+(n%2==0),n) a[i]=1;
	dp[0]=1,s=1;
	Dow(i,n,2){
		s+=a[i];
		For(j,s,n) upd(dp[j],dp[j-s]);
	}
	int ans=0;
	For(i,0,n) ans=(ans+1ll*dp[i]*(n-i))%mod;
	printf("%d\n",ans);
}