#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int mod = 998244353;
inline int mul(int x,int y){return 1ll*x*y%mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int sq(int x){return 1ll*x*x%mod;}
int pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}


int n;
int dp[5050] = {0};
void upd(int i){
	for(int j=i;j<=n;j++){
		dp[j] = add(dp[j],dp[j-i]);
	}
}
int main() {
	read(n);read(mod);
	dp[0] = 1;
	if(n%2 == 1){
		int k = (n-1)/2;
		for(int i=1;i<=k+1;i++)upd(i);
		for(int i=k;i>=2;i--)upd(i);
	}else{
		int k = n/2;
		for(int i=1;i<=k;i++)upd(i);
		for(int i=k;i>=2;i--)upd(i);
	}
	int ans = 0;
	for(int i=0;i<=n;i++){
		ans = add(ans,mul(dp[i],n-i));
	}
	cout<<ans<<endl;
	return 0;
}
