// Written by newbiechd
#include <cstdio>

const int maxN = 5003;
int dp[maxN];
inline int min(int x, int y) { return x < y ? x : y; }

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