#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int MOD;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}

const int N = 5010;
int n;
int dp[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &MOD);
	dp[n] = 1;
	for (int p = n; p > 0; p--) {
		int z = p;
		z -= max(0, p - (n + 1) / 2);
		z -= max(0, p - n / 2 - 1);
		if (z <= 0) throw;
		for (int x = n; x > z; x--) {
			dp[x - z] = add(dp[x - z], dp[x]);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = add(ans, dp[i]);
	printf("%d\n", ans);

	return 0;
}
