/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 5e3 + 5;
int n, P, dp[N] = {1};

int main() {
	cin >> n >> P;
	for (int i = 1; i < n; i++)
		for (int x = min(i, n - i + 1), j = x; j < n; j++)
			(dp[j] += dp[j - x]) %= P;
	int ans = 0;
	for (int i = 0; i < n; i++)
		(ans += 1LL * (n - i) * dp[i] % P) %= P;
	cout << ans;
}
