#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int MOD;
int N;
int dp[5050][5050]; // diff, penalty sum

void compute(int L)
{
	for (int i = 0; i <= N; ++i) for (int j = 0; j <= N; ++j) dp[i][j] = 0;
	dp[0][0] = 1;

	for (int i = 0; i < L; ++i) {
		int mxd = N / (L - i);
		for (int j = 0; j <= mxd; ++j) {
			for (int k = 0; k <= N; ++k) {
				if (dp[j][k] && k + L - i <= N) {
					ADD(dp[j + 1][k + (L - i)], dp[j][k]);
				}
			}
		}
	}
}

int ls[5050];

int main()
{
	scanf("%d%d", &N, &MOD);

	i64 ans;
	if (N % 2 == 0) {
		compute(N / 2);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		for (int i = 0; i <= N; ++i) ls[i] = dp[N][i];
		for (int j = 1; j <= N; ++j) ADD(ls[j], ls[j - 1]);
		compute(N / 2 - 1);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		ans = 0;
		for (int i = 1; i <= N; ++i) {
			i64 tmp = 0;
			for (int j = 0; j < i; ++j) {
				// left penalty sum < i - j
				ADD(tmp, (i64)dp[N - i][j] * ls[i - j - 1]);
			}
			ADD(ans, tmp);
		}
	} else {
		compute(N / 2);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		for (int i = 0; i <= N; ++i) ls[i] = dp[N][i];
		for (int j = 1; j <= N; ++j) ADD(ls[j], ls[j - 1]);
		ans = 0;
		for (int i = 1; i <= N; ++i) {
			i64 tmp = 0;
			for (int j = 0; j < i; ++j) {
				// left penalty sum < i - j
				ADD(tmp, (i64)dp[N - i][j] * ls[i - j - 1]);
			}
			ADD(ans, tmp);
		}
	}
	printf("%lld\n", ans);
	return 0;
}
