#include <bits/stdc++.h>
using namespace std;
char c;
inline void read(long long& a) {
  a = 0;
  do c = getchar();
  while (c < '0' || c > '9');
  while (c <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0', c = getchar();
}
long long n, d, Mod, F[1001], G[11][1001], Rev[10];
inline long long C(long long x, long long y) {
  long long r = Rev[y];
  for (long long i = x; i < x + y; i++) r = r * i % Mod;
  return r;
}
int main() {
  read(n), read(d), read(Mod);
  if (n == 1) return puts("1"), 0;
  if ((n - 2) % (d - 1)) return puts("0"), 0;
  n = (n - 2) / (d - 1);
  Rev[0] = Rev[1] = 1;
  for (int i = 2; i <= d; i++) Rev[i] = (Mod - Mod / i) * Rev[Mod % i] % Mod;
  for (int i = 2; i <= d; i++) Rev[i] = Rev[i] * Rev[i - 1] % Mod;
  F[0] = 1;
  for (int i = 0; i <= d; i++) G[i][0] = 1;
  for (int i = 1; i <= n >> 1; i++) {
    F[i] = G[d - 1][i - 1];
    if (i + i < n)
      for (int j = d; j; j--)
        for (int l = i; l <= n; l++)
          for (int k = 1; k <= j && i * k <= l; k++)
            G[j][l] = (G[j][l] + G[j - k][l - i * k] * C(F[i], k)) % Mod;
  }
  cout << (G[d][n - 1] + (n & 1 ? 0 : C(F[n >> 1], 2))) % Mod << endl;
  return 0;
}
