//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 5000 + 10;
int MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, DP[N][N], zar[N], sm[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> MOD;
	int k = (n / 2) + 1;
	for (int i = 2; i <= n; i++){
		if (i <= k) zar[i] = i - 1;
		else zar[i] = n - i + 2;
//		cout << zar[i] << '\n';
	}
	DP[1][0] = 1;
	for (int i = 2; i <= n; i++){
		memset(sm, 0, sizeof sm);
		for (int j = 0; j <= n; j++) sm[j] = ((j >= zar[i]?sm[j - zar[i]]:0) + DP[i - 1][j]) % MOD;
		for (int sum = 0; sum <= n; sum ++){
			DP[i][sum] = sm[sum];
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) ans = (ans + (n - i) * 1ll * DP[n][i] % MOD) % MOD;
	cout << ans;








	return 0;
}
