/*

a[n-1] < a[0] + a[1]
		STATE
a[n-1] + a[n-2] < a[0] + a[1] + a[2]  <--- then this is true too
a[n-1] + a[n-2] + a[n-3] < a[0] + a[1] + a[2] + a[3]   <--- if this is true

n=9

a[1] <= a[2] <= ... <= a[n]
a[1] + ... + a[5] > a[6] + ... + a[9]
a[1] := A[5] - A[1] >= 0
a[7] := A[7] - A[5]
5 * A[5] - a[1] - a[2] - a[3] - a[4] > 4 * A[5] + a[6] + a[7] + a[8] + a[9]
A[5] - a[1] - a[2] - a[3] - a[4] > a[6] + a[7] + a[8] + a[9]
A[5] > a[1] + a[2] + a[3] + a[4] + a[6] + a[7] + a[8] + a[9]



											a[9] + ... a[6] < a[0] + ... + a[4]

2 5 8 8 12 15 20 | ............

(20-15)+(20-12)+... = diff

dp[i][value][diff]
		diff = 20*i - sum  <= N
...
a[n-1] + ... + a[3] < a[0] + ... + a[n-3]         a[n-1] + a[n-2] < a[0] + a[1] + a[2]
a[n-1] + ... + a[2] < a[0] + a[1] + ... + a[n-2]        a[n-1] < a[0] + a[1]


1 2 3 4 5 6 7 8
X X *       * X

dp[i=1][value 1][value n-1][difference]
O(N^6) states and O(N^2) transitions per state


2^N .. 2^(2N)









width = N / 2
for(height)
	for(areaAbove)
		ways = ...

.......XXXXXX
...XXXXX.....
...X.........
...X.........
..XX.........
XXX..........
X............

 2 2 3 6 6 6 6 7 7 7 7 7
1 0 1 3 0 0 0 1 0 0 0 0   sum(value)=height
    
    sum(value * i) = areaAbove

dp[i][sum][areaAbove]




I give up with O(N^2) approach, and just try to get O(N^2 log(N)).


After seeing some part of the editorial:

x[i] = A[i] - A[i-1]
x[1] + x[2] + ... + x[n] <= N - 1

a[1] + ... + a[5] > a[6] + ... + a[9]
a[1] > -a[2] - a[3] - a[4] - a[5] + a[6] + a[7] + a[8] + a[9]
a[1] > -(a[1] + x[2] + a[1] + x[2] + x[3] + ... + a[1] + x[2] + x[3] + x[4] + x[5])
	   +(a[1] + x[2..6] + a[1] + x[2..7] + a[1] + x[2..8] + a[1] + x[2..9])

a[1] > x[3..9] + x[4..8] + x[5..7] + x[6..6]
 

x[1] + ... + x[n] <= N - 1
									BAD IDEA: x[i] := x[i]+1

x[1]>= x[1..n] * (0, 0, 1, 2, 3, 4, 3, 2, 1)
                       3  4  5  6  7  8  9
                      
                 (0, 0, 1, 1, 2, 2, 3, 3, 4, 4) <--- n = 10

			  1  2  3  4  5  6
          (1, 2, 3, 4, 5, 6, 7)
                 ^     ^      
                   
                   
                   1 2 3
                   ^   ^
               1 2 3 4 5

			dp[sum][weightedSum]
		-> dp[sum+x][weightedSum+sum+x]

x[1] + sum <= N - 1
x[1] >= weightedSum			    

dp[i][sum][weightedSum]


x[2..N] * (1, 2, ..., 2) = sum+weightedSum <= N

dp[i][sum]

*/
#include <bits/stdc++.h>
using namespace std;
int mod;
void add_self(int& a, int b) {
	a += b;
	if(a >= mod) {
		a -= mod;
	}
}
int main() {
	int n;
	cin >> n >> mod;
	vector<vector<int>> dp(n + 2, vector<int>(n + 1));
	dp[2][0] = 1;
	for(int i = 2; i <= n; i++) {
		for(int sum = 0; sum <= n; ++sum) {
			int me = dp[i][sum];
			if(!me) {
				continue;
			}
			int multiplier = min(i - 2 + 1, n - i + 2);
			for(int val = 0; true; ++val) { // O(N / i) -> the sum of this is O(N*log(N))
				int sum2 = sum + multiplier * val;
				if(sum2 > n) {
					break;
				}
				add_self(dp[i+1][sum2], dp[i][sum]);
			}
		}
	}
	int answer = 0;
	for(int sum = 0; sum <= n; ++sum) {
		answer = (answer + (long long) dp[n+1][sum] * (n - sum)) % mod;
	}
	cout << answer << endl;
	
	/*int answer = 0;
	for(int sum = 0; sum <= n - 1; sum++) {
		for(int weightedSum = 0; weightedSum <= n - 1; ++weightedSum) {
			int me = dp[sum][weightedSum]; // number of ways
			if(!me) {
				continue;
			}
			if(sum > 0 && weightedSum+sum < n) dp[sum][weightedSum+sum] += me; // adding 0
			for(int x = 1; x <= n; x++) {
				int sum2 = sum + x;
				int wei2 = weightedSum+sum+x;
				if(sum2 >= n || wei2 >= n) {
					continue;
				}
				dp[sum2][wei2] += me;
				for(int extra = 0; wei2 + sum2 * extra <= n; ++extra) {
					// (sum2, wei2 + sum2 * extra)
					for(int x1 = weightedSum; x1 + sum <= n - 1; ++x1) {
						answer += me;
					}
				}
			}
		}
	}
	cout << answer << endl;*/
}










Measured memory_bytes: 99712