#include <bits/stdc++.h>
using namespace std;
int MOD;
template <int& MOD_>
struct modnum {
  static constexpr int& MOD = MOD_;

 private:
  using ll = long long;
  int v;
  static int minv(int a, int m) {
    a %= m;
    assert(a);
    return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
  }

 public:
  modnum() : v(0) {}
  modnum(ll v_) : v(int(v_ % MOD)) {
    if (v < 0) v += MOD;
  }
  explicit operator int() const { return v; }
  friend std::ostream& operator<<(std::ostream& out, const modnum& n) {
    return out << int(n);
  }
  friend std::istream& operator>>(std::istream& in, modnum& n) {
    ll v_;
    in >> v_;
    n = modnum(v_);
    return in;
  }
  friend bool operator==(const modnum& a, const modnum& b) {
    return a.v == b.v;
  }
  friend bool operator!=(const modnum& a, const modnum& b) {
    return a.v != b.v;
  }
  modnum inv() const {
    modnum res;
    res.v = minv(v, MOD);
    return res;
  }
  modnum neg() const {
    modnum res;
    res.v = v ? MOD - v : 0;
    return res;
  }
  modnum operator-() const { return neg(); }
  modnum operator+() const { return modnum(*this); }
  modnum& operator++() {
    v++;
    if (v == MOD) v = 0;
    return *this;
  }
  modnum& operator--() {
    if (v == 0) v = MOD;
    v--;
    return *this;
  }
  modnum& operator+=(const modnum& o) {
    v += o.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }
  modnum& operator-=(const modnum& o) {
    v -= o.v;
    if (v < 0) v += MOD;
    return *this;
  }
  modnum& operator*=(const modnum& o) {
    v = int(ll(v) * ll(o.v) % MOD);
    return *this;
  }
  modnum& operator/=(const modnum& o) { return *this *= o.inv(); }
  friend modnum operator++(modnum& a, int) {
    modnum r = a;
    ++a;
    return r;
  }
  friend modnum operator--(modnum& a, int) {
    modnum r = a;
    --a;
    return r;
  }
  friend modnum operator+(const modnum& a, const modnum& b) {
    return modnum(a) += b;
  }
  friend modnum operator-(const modnum& a, const modnum& b) {
    return modnum(a) -= b;
  }
  friend modnum operator*(const modnum& a, const modnum& b) {
    return modnum(a) *= b;
  }
  friend modnum operator/(const modnum& a, const modnum& b) {
    return modnum(a) /= b;
  }
};
using num = modnum<MOD>;
const int MAXN = 160;
const int MAXK = MAXN;
num dp1[MAXN];
num solve1K(int n, int k) {
  assert(k >= 1);
  dp1[0] = 1;
  num sum = dp1[0];
  for (int i = 1; i <= n + 1; i++) {
    dp1[i] = sum;
    sum += dp1[i];
    if (i >= k + 1) sum -= dp1[i - (k + 1)];
  }
  return dp1[n + 1];
}
num go(int N, int K) {
  if (K % 2 == 0) {
    num a = solve1K(N / 2, K / 2);
    num b = solve1K(N - N / 2, K / 2);
    return a * b;
  } else if (K == 1) {
    return solve1K(N, 2);
  } else {
    assert(K >= 3);
    using half_state = pair<int, int>;
    using state = pair<half_state, half_state>;
    map<state, num> dp;
    dp[state()] = 1;
    for (int i = 1; i <= N; i++) {
      map<state, num> ndp;
      for (auto it : dp) {
        const num cnt = it.second;
        {
          const state s = it.first;
          state ns(half_state(0, 0), s.first);
          if (ns.second.first == K / 2 + 1) {
            ns.second.first = K / 2;
            ns.second.second = 0;
          } else if (ns.second.first <= K / 2) {
            ns.second.second = 0;
          }
          ndp[ns] += cnt;
        }
        {
          const state s = it.first;
          state ns(half_state(s.second.first + 1, s.second.second), s.first);
          if (ns.second.first == K / 2 + 1) {
            ns.second.first = K / 2 + 1 + ns.second.second;
            ns.second.second = 0;
            assert(ns.second.second == 0);
          } else if (ns.second.first <= K / 2) {
            ns.second.second = min(ns.second.second + 1, ns.second.first);
          }
          if (ns.first.first <= K) {
            ndp[ns] += cnt;
          } else
            assert(ns.first.first == K + 1);
        }
      }
      dp = std::move(ndp);
    }
    num ans = 0;
    for (auto it : dp) {
      ans += it.second;
    }
    return ans;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N, K;
  cin >> N >> K >> MOD;
  num ans = go(N, K);
  cout << int(ans) + 1 << '\n';
  return 0;
}
