#include<bits/stdc++.h>
using namespace std;
const int N=5050;
int n,m,c[N],f[N],ans;
int main(){
    scanf("%d%d",&n,&m);f[0]=1;
    for(int i=3,j=n;i<=j;i++,j--)c[i]=c[j]=i-2;
    for(int i=2;i<=n;i++)
        for(int j=c[i]+1;j<=n;j++)(f[j]+=f[j-c[i]-1])%=m;
    for(int i=0;i<n;i++)ans=(ans+1ll*f[i]*(n-i))%m;
    printf("%d\n",ans);
    return 0;
}