/*
 * Author       : YangDavid
 * Created Time : 2020年01月13日 星期一 20时00分57秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

/*
   Let A_i = 1 + x_1 + x_2 + ... + x_i
   Find the sum of max(N-[x_2,x_3,...,x_n] \cdot [1,2,...,3,2], 0)
     for all nonnegative x_i.
 */
const int maxn = 5555;
int n, MOD;
int add(int x, int y) { return x+y>=MOD ? x+y-MOD : x+y; }
int sub(int x, int y) { return x-y<0 ? x-y+MOD : x-y; }
int mul(int x, int y) { return 1LL*x*y%MOD; }

int dp[maxn];
int main() {
	scanf("%d%d", &n, &MOD);
	dp[0] = 1;
	for(int i = 1; i < n; ++i) {
		int j = i/2 + 1;
		for(int c = 0; c <= n-j; ++c) {
			dp[c + j] = add(dp[c + j], dp[c]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; ++i)
		ans = add(ans, mul(dp[i], n - i));
	printf("%d\n", ans);

    return 0;
}
