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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;

int n,mod,f[5005][5005],a[maxn],g[10002];

int main() {
    read(n),read(mod);
    f[1][n]=1;a[2]=1;
    for(int i=3,j=n;i<=j;i++,j--) a[i]=a[j]=a[i-1]+1;
    for(int x=2;x<=n;x++) 
        for(int i=n;i;i--) f[x][i]=((i+a[x]<=n?f[x][i+a[x]]:0)+f[x-1][i])%mod;
    int ans=0;
    for(int i=1;i<=n;i++) ans=(ans+1ll*i*f[n][i]%mod)%mod;
    write(ans);
    return 0;
}
