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

const int N = 5010;
long long dp[N];

int main() {
  int n;
  int m;
  scanf("%d%d", &n, &m);
  dp[0] = 1;
  for (int i = 1; i < n; i++) {
    int coef = min(i, n - i + 1);
    for (int j = coef; j < n; j++) {
      dp[j] += dp[j - coef];
      dp[j] %= m;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[i] * (n - i) % m;
    ans %= m;
  }

  cout << ans << endl;
  return 0;
}
