#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<ll> vl;

ll mod;
int n;

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

	cin >> n >> mod;

	vl cnt(n+1);
	cnt[n] = 1;
	rep(i,1,n){
		int c = min(i, n+1-i);
		rrep(j,c,n+1) cnt[j-c] = (cnt[j-c]+cnt[j]) % mod;
	}
	ll ans = 0;
	rep(i,1,n+1) ans += i * cnt[i];
	cout << ans % mod << endl;
}
