#include <bits/stdc++.h>
using namespace std;
const unsigned _mod = 998244353;
unsigned mod;
const long long infi = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long qpow(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1ll) ret = ret * x;
    y >>= 1ll;
    x = x * x;
  }
  return ret;
}
long long ksm(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1ll) ret = ret * x % mod;
    y >>= 1ll;
    x = x * x % mod;
  }
  return ret;
}
long long _gcd(long long x, long long y) { return y ? _gcd(y, x % y) : x; }
long long fac[250010], inv[250010], n, k, ans, hr[250010], f[27][250010], res;
int main() {
  cin >> n >> k >> mod;
  fac[0] = inv[0] = 1;
  for (int i = 1; i <= 250000; ++i) fac[i] = fac[i - 1] * i % mod;
  for (int i = 1; i <= 250000; ++i) inv[i] = ksm(fac[i], mod - 2);
  for (int i = 1; i / 2 <= n; i *= 2)
    for (int j = i / 2; j <= min(i - 1ll, n); ++j) hr[j] = i;
  ans = ksm(k, n);
  if (n & 1) return cout << ans << '\n', 0;
  f[0][0] = 1;
  for (int i = 0; i <= 25; ++i)
    for (int j = 0; j <= n; ++j)
      if (f[i][j])
        if ((j & n) == j)
          for (int k = j + hr[j]; k <= n; k = (k + 1) | j)
            if ((k & n) == k)
              f[i + 1][k] += f[i][j] * inv[k - j], f[i + 1][k] %= mod;
  for (int i = 1; i <= min(k, 26ll); ++i)
    res += f[i][n] * inv[k - i], res %= mod;
  ans += mod - res * fac[n] % mod * fac[k] % mod;
  cout << ans % mod << '\n';
  return 0;
}
