/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 5e3 + 10;

int wt[N];
ll dp[N][N];

int main() {
	fast_cin();
	int n, mod;
	cin >> n >> mod;
	int k = (n - 1) / 2;
	for (int i = 2; i <= n; ++i) {
		if (i < n - k + 1) {
			wt[i] = i - 1;
		} else {
			wt[i] = n + 2 - i;
		}
	}
	dp[1][n] = 1;
	for (int i = 1; i < n; ++i) {
		for (int val = n; val >= 1; --val) {
			dp[i + 1][val] += dp[i][val];
			dp[i + 1][val] %= mod;
			if (val > wt[i + 1]) {
				dp[i][val - wt[i + 1]] += dp[i][val];
				dp[i][val - wt[i + 1]] %= mod;
			}
			// dp[i][val] %= mod;
			// int max_x = val / wt[i + 1];
			// for (int x = 0; x <= max_x; ++x) {
			// 	dp[i + 1][val - x * wt[i + 1]] += dp[i][val];
			// }
		}
	}
	ll ans = 0;
	for (int val = 1; val <= n; ++val) {
		ans += val * dp[n][val];
		ans %= mod;
	}
	cout << ans << endl;
}