#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=120;

int dp[maxn][maxn][maxn];
int NB[maxn][maxn][maxn];

int n,m,k,mod;
int p2[maxn];

inline void init()
{
	n=read();  k=read();mod=read();
	m=n+1>>1; n>>=1;
	p2[0]=1;
	REP(i,1,100)p2[i]=p2[i-1]*2%mod;
}

inline void pls(int &a,int b){ a+=b; a-=a>=mod?mod:0;}

inline void doing()
{
	if(~k&1)
	{
		static int f[maxn];
		k>>=1; 
		int ans=1;
		f[0]=1;
		REP(i,1,n+1)REP(j,1,k+1)if(i>=j)f[i]=(f[i]+f[i-j])%mod;
		ans=(ll)ans*f[n+1]%mod;
		memset(f,0,sizeof(f));
		f[0]=1;
		REP(i,1,m+1)REP(j,1,k+1)if(i>=j)f[i]=(f[i]+f[i-j])%mod;
		ans=(ll)ans*f[m+1]%mod;
		printf("%d\n",ans);
	}else
	{
		int ans=0;
		pls(ans,p2[m]);
		k>>=1;
		REP(i,1,n)REP(j,1,i)
		{
			int l=j+k+1,r=i-k;
			if(l<=r)
			{
				pls(dp[i][j][0],p2[l-1]);
				REP(a,i+2,n)REP(b,a,n)
				{
					int nl=a+k+1,nr=b-k;
					assert(nr>0);
					if(nl<=nr)pls(dp[b][a][0],(ll)dp[i][j][0]*p2[nl-r-1]%mod);
					else if(nl>m)pls(dp[b][a][0],(ll)dp[i][j][0]*p2[m-r]%mod);
					else pls(dp[b][a][nr-1],(ll)dp[i][j][0]*p2[nr-r-1]%mod);
				}
				pls(ans,(ll)dp[i][j][0]*p2[m-r]%mod);
			}
			else if(r<=0)
			{
				pls(dp[i][j][0],1);
				REP(a,i+2,n)REP(b,a,n)
				{
					int nl=a+k+1,nr=b-k;
					//assert(nr>0);
					if(nl<=nr)pls(dp[b][a][0],(ll)dp[i][j][0]*p2[nl-1]%mod);
					else if(nr<=0)pls(dp[b][a][0],dp[i][j][0]);
					else if(nl>m)pls(dp[b][a][0],(ll)dp[i][j][0]*p2[m]%mod);
					else pls(dp[b][a][nr-1],(ll)dp[i][j][0]*p2[nr-1]%mod);
				}
				pls(ans,(ll)dp[i][j][0]*p2[m]%mod);
			}
			else if(l>m)
			{
				pls(dp[i][j][0],p2[m]);
				REP(a,i+2,n)REP(b,a,n)
				{
					//int nl=a+k,nr=b-k-1;
					//if(nl<=nr)pls(dp[a][b][0],(ll)dp[i][j][0]*p2[nl-1]%mod);
					//else if(nr<=0)pls(dp[a][b][0],dp[i][j][0]);
					pls(dp[b][a][0],dp[i][j][0]);
					//else pls(dp[a][b][nr-1],(ll)dp[i][j][0]*p2[nr-1]%mod);
				}
				pls(ans,dp[i][j][0]);
			}else {
				pls(dp[i][j][r-1],p2[r-1]);
				int s=dp[i][j][r-1],ns=0;
				REP(x,r,l)
				{
					int t=dp[i][j][x]; dp[i][j][x]=s;
					pls(s,dp[i][j][x]); pls(s,t);
				}
				REP(x,r,l)pls(dp[i][j][x],NB[i][j][x]);
				REP(x,r,l)pls(ns,dp[i][j][x]);
				REP(a,i+2,n)REP(b,a,n)
				{
					int nl=a+k+1,nr=b-k;
					//assert(nr>0);
					if(nl<=nr)pls(dp[b][a][0],(ll)ns*p2[nl-l-1]%mod);
					else if(nl>m)pls(dp[b][a][0],(ll)ns*p2[m-l]%mod);
					else if(l<nr)pls(dp[b][a][nr-1],(ll)ns*p2[nr-l-1]%mod);
					else{
						REP(x,r,l)
						{
							if(x<nr)pls(dp[b][a][l],dp[i][j][x]);
							else if(x>=nr)pls(dp[b][a][l],dp[i][j][x]),pls(NB[b][a][x],dp[i][j][x]);
						}
					}
				}
				REP(x,r,l)pls(ans,(ll)dp[i][j][x]*p2[m-l]%mod);
			}
		}
		printf("%d\n",ans);
	}
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 10752