#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
const int maxn=155;
int n,m,mod;
namespace subtask1
{
	map<pii,int> f[maxn][maxn][maxn];
	inline void solve()
	{
		f[0][0][0][pii(n+1,n+1)]=1;
		for(int i=0;i<n;i++)
			for(int j=0;j<=n;j++)
				for(int k=0;k<=n;k++)
					for(auto it:f[i][j][k])
					{
						int p=it.fi.fi,q=it.fi.se,val=it.se;
						if(!(i&1))
						{
							(f[i+1][0][k][pii(n+1,q)]+=val)%=mod;
							if(p>i+1)
							{
								if(i+2-2*k+m<=i+1 && i+1-2*j+m>i)
									(f[i+1][j+1][k][pii(p,min(q,i+1-2*j+m))]+=val)%=mod;
								else
									(f[i+1][j+1][k][pii(p,q)]+=val)%=mod;
							}
						}
						else
						{
							(f[i+1][j][0][pii(p,n+1)]+=val)%=mod;
							if(q>i+1)
							{
								if(i+2-2*j+m<=i+1 && i+1-2*k+m>i)
									(f[i+1][j][k+1][pii(min(p,i+1-2*k+m),q)]+=val)%=mod;
								else
									(f[i+1][j][k+1][pii(p,q)]+=val)%=mod;
							}
						}
					}
		int res=0;
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
				for(auto it:f[n][j][k])
					(res+=it.se)%=mod;
		printf("%d\n",res);
	}
}
namespace subtask2
{
	int f[maxn];
	inline void solve()
	{
		f[0]=1;
		int len=m/2+1;
		for(int i=1;i<=n/2+1;i++)
			f[i]=(2ll*f[i-1]-((i>=len)?f[i-len-(i!=len)]:0)+mod)%mod;
		printf("%lld\n",(ll)f[n>>1]*f[(n+1)>>1]%mod);
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&mod);
	if(m&1) subtask1::solve();
	else subtask2::solve();
	return 0;
}