#include <bits/stdc++.h>

using namespace std;

const int max_n = 5055;

int n, mod, dp[max_n];

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> mod;
    dp[0] = 1;
    int coef = 1;
    int cnt = n / 2;
    for (int i = 1; i < n; ++i) {
        for (int cur = n; cur >= 0; --cur) {
            int c = dp[cur];
            for (int x = 0; cur + x * coef <= n; ++x) {
                dp[cur + x * coef] += c;
                dp[cur + x * coef] %= mod;
            }
            dp[cur] += mod - c;
            dp[cur] %= mod;
        }
        if (cnt) {
            --cnt;
            ++coef;
            if (!cnt && n % 2 == 0) {
                --coef;
            }
        } else {
            --coef;
        }
    }
    int ans = 0;
    for (int x = 0; x <= n; ++x) {
        ans += mul(n - x, dp[x]);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
