#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
long long n, d, Mod, ans, f[MAXN][12], g[MAXN], inv[MAXN];
int main() {
  scanf("%lld%lld%lld", &n, &d, &Mod);
  if (n <= 2) {
    puts("1");
    return 0;
  }
  if ((n - 2) % (d - 1)) {
    puts("0");
    return 0;
  }
  inv[0] = inv[1] = 1;
  for (register int i = 2; i <= n; ++i)
    inv[i] = 1LL * (Mod - Mod / i) * inv[Mod % i] % Mod;
  for (register int i = 2; i <= n; ++i)
    inv[i] = 1LL * inv[i] * inv[i - 1] % Mod;
  g[1] = f[0][0] = 1;
  for (register int i = 1; i <= (n >> 1); ++i) {
    for (register int j = n - i; j >= 0; --j)
      for (register int p = 0; p < d; ++p)
        if (f[j][p]) {
          register long long w = 1;
          for (register int q = 1; p + q <= d && j + q * i <= n; ++q) {
            (w *= g[i] + q - 1) %= Mod;
            f[j + q * i][p + q] =
                (f[j + q * i][p + q] + 1LL * w * inv[q] % Mod * f[j][p] % Mod) %
                Mod;
          }
        }
    g[i + 1] = f[i][d - 1];
  }
  ans = f[n - 1][d];
  if (n & 1 ^ 1) (ans += Mod - (g[n >> 1] * (g[n >> 1] - 1) >> 1) % Mod) %= Mod;
  printf("%lld\n", ans);
  return 0;
}
