#include <bits/stdc++.h>
using namespace std;
const int N = 250000 + 7;
const bool multipleTest = 0;
int lt[N], invlt[N];
int n, k, p;
int inverse(int x, int n) {
  int r = n, newr = x;
  int t = 0, newt = 1;
  while (newr > 0) {
    int q = r / newr;
    int tmp = newr;
    newr = r % newr;
    r = tmp;
    tmp = newt;
    newt = t - q * newt;
    t = tmp;
  }
  if (t < 0) t += n;
  return t;
}
int C(int n, int k) {
  return (long long)lt[n] * invlt[n - k] % p * invlt[k] % p;
}
long long pw(long long x, long long k) {
  if (!k)
    return 1;
  else if (k & 1)
    return pw(x, k - 1) * x % p;
  long long tmp = pw(x, k / 2);
  return tmp * tmp % p;
}
pair<int, int> extended_eclid(int a, int b) {
  int s0 = 1, t0 = 0;
  int s1 = 0, t1 = 1;
  while (b > 0) {
    int q = a / b;
    int tmp = 0;
    tmp = s1;
    s1 = s0 - q * s1;
    s0 = tmp;
    tmp = t1;
    t1 = t0 - q * t1;
    t0 = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }
  return make_pair(s0, t0);
}
void init() {
  lt[0] = invlt[0] = 1;
  for (int i = 1; i < N; ++i) {
    lt[i] = (long long)lt[i - 1] * i % p;
    invlt[i] = inverse(lt[i], p);
  }
}
long long dp[N][18];
void solve() {
  cin >> n >> k >> p;
  init();
  long long res = pw(k, n);
  if (n & 1) {
    cout << res;
    return;
  }
  long long pp = 1ll * p * p;
  vector<int> child;
  for (int i = 1; i <= n; ++i)
    if ((i & n) == i) child.push_back(i);
  int _k = min(k, __builtin_popcount(n));
  int tol = 0;
  for (int& i : child) {
    dp[i][1] = 1;
    int last = i ^ (i & -i);
    for (int u = last; u; u = (u - 1) & last) {
      long long tmp = C(i, u);
      for (int len = 2; len <= _k; ++len) {
        ++tol;
        dp[i][len] += dp[u][len - 1] * tmp;
        if (dp[i][len] >= pp) dp[i][len] -= pp;
      }
    }
    for (int len = 2; len <= _k; ++len) dp[i][len] %= p;
  }
  for (int len = 1; len <= _k; ++len) {
    res = (res - 1ll * dp[n][len] * lt[k] % p * invlt[k - len]) % p;
    if (res < 0) res += p;
  }
  cout << res;
}
int main() {
  int Test = 1;
  if (multipleTest) {
    cin >> Test;
  }
  for (int i = 0; i < Test; ++i) {
    solve();
  }
}
