#include <bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> dp(N, 1);
    const auto& multiplies = [&N, &M, &dp](unsigned long a){
        vector<unsigned long> ans(N);
        for(unsigned long i{0}; i < N; ++i)for(unsigned long j{0}; i + j * a < N; ++j)ans[i + j * a] += dp[i];
        for(auto& i : ans)i %= M;
        copy(ans.begin(), ans.end(), dp.begin());
    };
    for(unsigned long i = 2; i < N; ++i)multiplies(min(i, N - i + 1));
    vector<unsigned long> coef(N);
    iota(coef.rbegin(), coef.rend(), 1UL);
    cout << inner_product(coef.begin(), coef.end(), dp.begin(), 0UL) % M << endl;
    return 0;
}