#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k;
ll mod,dp[2][155][155][155];

ll easy(int n,int m){
	for(int i=0;i<155;i++) for(int j=0;j<155;j++) dp[0][i][j][0] = 0;
	dp[0][0][0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(dp[0][i][j][0] == 0) continue;
			dp[0][i+1][0][0] += dp[0][i][j][0];
			if(dp[0][i+1][0][0]>=mod) dp[0][i+1][0][0]-=mod;
			if(j+1 == m) continue;
			dp[0][i+1][j+1][0] += dp[0][i][j][0];
			if(dp[0][i+1][j+1][0]>=mod) dp[0][i+1][j+1][0]-=mod;
		}
	}
	ll ret = 0;
	for(int j=0;j<m;j++) ret += dp[0][n][j][0];
	return (ret%mod+mod)%mod;
}

int main(){
	cin >> n >> k >> mod;
	if(k == 1){
		cout << easy(n,3) << endl;
	}
	else if(k%2 == 0){
		cout << easy(n/2,k/2+1)*easy(n-n/2,k/2+1)%mod << endl;
	}
	else{
		dp[0][0][0][0] = 1;
		int cur = 0,nxt = 1;
		for(int i=1;i<=n;i++){
			rep(a,155)rep(b,155)rep(c,155) dp[nxt][a][b][c] = 0;
			
			if(i%2 == 1){
				for(int a=0;a<i;a++){
					for(int b=0;b<i;b++){
						for(int c=0;c<155;c++){
							if(dp[cur][a][b][c] == 0) continue;
							//use
							bool bad = 0;
							if(c && c%2 == 1 && c <= i) bad = 1;
							if(!bad){
								int nwc = c;
								if(nwc == 0 && b && b+k <= i){
									if(a == 0) nwc = i+k;
									else nwc = a+k;
								}
								if(nwc > n) nwc = nwc%2 + (n+2)/2*2;
								int nwa = a;
								if(nwa == 0) nwa = i;
								dp[nxt][nwa][b][nwc] += dp[cur][a][b][c];
								if(dp[nxt][nwa][b][nwc] >= mod) dp[nxt][nwa][b][nwc] -= mod;
							}
							//not use
							int nwc = c;
							if(nwc%2 == 0);
							else{
								nwc = 0;
							}
							dp[nxt][0][b][nwc] += dp[cur][a][b][c];
							if(dp[nxt][0][b][nwc] >= mod) dp[nxt][0][b][nwc] -= mod;
						}
					}
				}
			}
			else{
				for(int a=0;a<i;a++){
					for(int b=0;b<i;b++){
						for(int c=0;c<155;c++){
							if(dp[cur][a][b][c] == 0) continue;
							//use
							bool bad = 0;
							if(c && c%2 == 0 && c <= i) bad = 1;
						//	if(b && (i-b) >= 2*k) bad = 1;
							if(!bad){
								int nwc = c;
								if(nwc == 0 && a && a+k <= i){
									if(b == 0) nwc = i+k;
									else nwc = b+k;
								}
								if(nwc > n) nwc = nwc%2 + (n+2)/2*2;
								int nwb = b;
								if(nwb == 0) nwb = i;
								dp[nxt][a][nwb][nwc] += dp[cur][a][b][c];
								if(dp[nxt][a][nwb][nwc] >= mod) dp[nxt][a][nwb][nwc] -= mod;
							}
							//not use
							int nwc = c;
							if(nwc%2 == 1);
							else{
								nwc = 0;
							}
							dp[nxt][a][0][nwc] += dp[cur][a][b][c];
							if(dp[nxt][a][0][nwc] >= mod) dp[nxt][a][0][nwc] -= mod;
						}
					}
				}
			}
			swap(cur,nxt);
		}
		ll ans = 0;
		for(int i=0;i<155;i++) for(int j=0;j<155;j++) for(int k=0;k<155;k++) ans += dp[cur][i][j][k];
		cout << (ans%mod+mod)%mod << endl;
	}
}