#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll n, m;
    cin >> n >> m;
    ll k = n + 1 >> 1;

    vector<ll> num(n + 1, 0);
    FOR(i, 2, n + 1) {
        int x = 0;
        if(i <= k + 1)
            x = 1;
        else if(i >= n - k + 3)
            x = -1;
        num[i] = num[i - 1] + x;
    }

    vector<ll> dp(n, 0);
    dp[0] = 1;
    FOR(i, 2, n + 1)
    rep(j, n - num[i]) {
        dp[j + num[i]] += dp[j];
        if(dp[j + num[i]] >= m) dp[j + num[i]] -= m;
    }

    ll ret = 0;
    rep(i, n)(ret += (n - i) * dp[i]) %= m;

    cout << ret << endl;

    return 0;
}