#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, P, dp[MAXN][MAXN][2];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(P), m = (n - 1) / 2;
	dp[0][0][0] = 1;
	for (int i = 1; i <= m; i++)
	for (int j = 0; j <= n; j++) {
		update(dp[i][j][1], dp[i - 1][j][0]);
		if (j >= i) update(dp[i][j][1], dp[i][j - i][1]);
		dp[i][j][0] = dp[i][j][1];
		if (j >= i) update(dp[i][j][0], dp[i][j - i][0]);
	}
	int ans = 0;
	if (n & 1) {
		for (int i = 1; i <= n; i++)
		for (int j = 0; j * (m + 1) <= n - i; j++)
			update(ans, dp[m][n - i - j * (m + 1)][0]);
	} else {
		for (int i = 1; i <= n; i++)
		for (int j = 0; j * (m + 1) <= n - i; j++)
			update(ans, 1ll * dp[m][n - i - j * (m + 1)][0] * (j + 1) % P);
	}
	cout << ans << endl;
	return 0;
}