#include<bits/stdc++.h>
using namespace std;

int dp[5003] , N , M;

int main(){
	cin >> N >> M; if(N == 2){puts("3"); return 0;}
	bool flg = 0; dp[0] = 1; if(!(N & 1)){flg = 1; --N;}
	for(int i = 1 ; i < N ; ++i){
		int val = i <= N / 2 ? i : N - i + 1;
		if(flg && i == N / 2 + 1)
			for(int j = N ; j >= val ; --j)
				for(int k = 1 ; k * val <= j ; ++k)
					dp[j] = (dp[j] + 1ll * dp[j - k * val] * (k + 1)) % M;
		else
			for(int j = val ; j <= N ; ++j) dp[j] = (dp[j] + dp[j - val]) % M;
	}
	N += flg; int sum = N;
	for(int i = 1 ; i < N ; ++i) sum = (sum + 1ll * (N - i) * dp[i]) % M;
	cout << sum; return 0;
}