#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;

int mod;

struct mint {
	int val;
	mint() { val = 0; }
	mint(const lint& v) {
		val = (-mod <= v && v < mod) ? v : v % mod;
		if (val < 0) val += mod;
	}

	friend ostream& operator<<(ostream& os, const mint& a) { return os << a.val; }
	friend bool operator==(const mint& a, const mint& b) { return a.val == b.val; }
	friend bool operator!=(const mint& a, const mint& b) { return !(a == b); }
	friend bool operator<(const mint& a, const mint& b) { return a.val < b.val; }

	mint operator-() const { return mint(-val); }
	mint& operator+=(const mint& m) { if ((val += m.val) >= mod) val -= mod; return *this; }
	mint& operator-=(const mint& m) { if ((val -= m.val) < 0) val += mod; return *this; }
	mint& operator*=(const mint& m) { val = (lint)val*m.val%mod; return *this; }
	friend mint ipow(mint a, lint p) {
		mint ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mint inv(const mint& a) { assert(a.val); return ipow(a, mod - 2); }
	mint& operator/=(const mint& m) { return (*this) *= inv(m); }

	friend mint operator+(mint a, const mint& b) { return a += b; }
	friend mint operator-(mint a, const mint& b) { return a -= b; }
	friend mint operator*(mint a, const mint& b) { return a *= b; }
	friend mint operator/(mint a, const mint& b) { return a /= b; }
	operator int64_t() const {return val; }
};

mint ez(int n, int k){
	vector<mint> dp(n + 2);
	dp[0] = mint(1);
	for(int i=1; i<=n+1; i++){
		for(int j=1; j<=k+1 && j<=i; j++){
			dp[i] += dp[i - j];
		}
	}
	return dp[n + 1];
}

vector<int> v;
mint dp[155][155][155][2], nxt[155][155][155][2];
mint sex[155][155][155];
int kk;

int adj[20][20];
bool in(int msk, int val){
	if(val > 20 || val < 0) return 0;
	return (msk >> val) & 1;
}

int g(int n, int k){
	int ret = 0;
	for(int i=0; i<(1<<n); i++){
		memset(adj, 0, sizeof(adj));
		for(int j=0; j<n; j++){
			if(in(i, j - 2)) adj[j][j - 2] = 1;
			if(in(i, j + k)) adj[j][j + k] = 1;
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<n; k++){
					adj[j][k] |= (adj[j][i] & adj[i][k]);
				}
			}
		}
		bool good = 1;
		for(int i=0; i<n; i++) if(adj[i][i]) good = 0;
		ret += good;
	}
	return ret;
}

mint f(int pos, int l, int dp){
	if(dp >= kk) return mint(0);
	if(pos == sz(v)) return mint(1);
	if(sex[pos][l][dp]) return sex[pos][l][dp];
	mint ret = f(pos + 1, 0, 0);
	if(v[pos] & 1){
		ret += f(pos + 1, l + 1, 0);
	}
	if(v[pos] & 2){
		ret += f(pos + 1, 0, dp ? (dp + 1) : 0);
	}
	if(v[pos] == 3){
		ret += f(pos + 1, l + 1, max(l + 2, dp + 1));
	}
	return sex[pos][l][dp] = ret;
}

mint solve(int n, int thr){
	kk = thr;
	return f(0, 0, 0);
	dp[0][0][0][0] = 1;
	for(auto &x : v){
		memset(nxt, 0, sizeof(nxt));
		for(int i=0; i<=n; i++){ // short
			for(int j=0; j<=n; j++){ // long
				for(int k=0; k<=thr; k++){ // long with tail
					for(int l=0; l<2; l++){ // 1 if up is long
						if((lint)dp[i][j][k][l] == 0) continue;
						nxt[0][0][0][0] += dp[i][j][k][l];
						int next_k = 0;
						if(k > 0) next_k = k + 1;
						else if(i > 0) next_k = i + 2;
						if(x & 1){
							if(l == 0){
								if(i > 0) nxt[0][i + 1][j + 2][l ^ 1] += dp[i][j][k][l];
								else nxt[0][1][0][l ^ 1] += dp[i][j][k][l];
							}
							else{
								nxt[0][j + 1][next_k][l] += dp[i][j][k][l];
							}
						}
						if(x & 2){
							if(l == 1){
								if(i > 0) nxt[0][i + 1][j + 2][l ^ 1] += dp[i][j][k][l];
								else nxt[0][1][0][l ^ 1] += dp[i][j][k][l];
							}
							else{
								nxt[0][j + 1][next_k][l] += dp[i][j][k][l];
							}
						}
						if(x == 3){
							nxt[i + 1][j + 1][k ? (k + 1) : 0][l] += dp[i][j][k][l];
						}
					}
				}
			}
		}
		for(int i=0; i<=n; i++){
			for(int j=0; j<=n; j++){
				for(int k=0; k<thr; k++){
					if(i > 0 && j >= thr - 1){
						nxt[i][j][k][0] = nxt[i][j][k][1] = mint(0);
					}
					dp[i][j][k][0] = nxt[i][j][k][0];
					dp[i][j][k][1] = nxt[i][j][k][1];
				}
			}
		}
	}
	mint ret = 0;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=n; j++){
			for(int k=0; k<=thr; k++){
				for(int l=0; l<2; l++) ret += dp[i][j][k][l];
			}
		}
	}
	return ret;
}

int main(){
	int n, k;
	cin >> n >> k >> mod;
	if(k % 2 == 0){
		cout << ez((n + 1) / 2, k / 2) * ez(n / 2, k / 2) << endl;
		return 0;
	}
	for(int i=1; i<=n+n; i+=2){
		if(i - k > n) break;
		int msk = 0;
		if(i <= n) msk |= 1;
		if(i - k >= 1) msk |= 2;
		v.push_back(msk);
	}
	mint ret = solve(n, k + 2);
	cout << ret << endl;
}



Measured memory_bytes: 76380