#include <bits/stdc++.h>
using namespace std;
long long binPow(long long a, int b, int p) {
  if (b == 0) return 1;
  long long x = binPow(a, b / 2, p);
  x *= x;
  x %= p;
  if (b & 1) {
    x *= a;
    x %= p;
  }
  return x;
}
int n, k, p;
const int MAXN = 250250;
long long fact[MAXN], rfact[MAXN];
long long pw[MAXN];
int cnt = 0;
long long g[MAXN][17];
void solve(int n, const vector<int> &bit, int k, int l) {
  if (k == (int)(bit).size()) {
    ++cnt;
    for (int i = 1; i < 17; ++i) {
      g[n][i] += rfact[l] * g[n ^ l][i - 1];
      if (cnt >= 8) {
        g[n][i] %= p;
      }
    }
    if (cnt >= 8) cnt = 0;
    return;
  }
  solve(n, bit, k + 1, l);
  solve(n, bit, k + 1, l ^ (1 << bit[k]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> p;
  if (n & 1) {
    cout << binPow(k, n, p) << "\n";
    return 0;
  }
  fact[0] = 1;
  rfact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = fact[i - 1] * i % p;
    rfact[i] = binPow(fact[i], p - 2, p);
  }
  g[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    if ((i & n) != i) continue;
    vector<int> bit;
    for (int j = 0; j < 18; ++j) {
      if ((1 << j) & i) bit.push_back(j);
    }
    solve(i, bit, 1, 1 << bit[0]);
    for (int j = 0; j < 17; ++j) g[i][j] %= p;
  }
  long long ans = 0;
  for (int i = 1; i <= min(16, k); ++i) {
    g[n][i] %= p;
    long long cur = fact[n] * g[n][i];
    cur %= p;
    cur *= fact[k];
    cur %= p;
    cur *= rfact[k - i];
    cur %= p;
    ans += cur;
    ans %= p;
  }
  ans = binPow(k, n, p) - ans;
  if (ans < 0) ans += p;
  cout << ans << "\n";
  return 0;
}
