#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 10, D = 15;
int n, d, mod;
int dp[D][N][N];
int ifac[N];
void Add(int &x, int y) {
  if ((x += y) >= mod && (x -= mod))
    ;
}
int binom(int n, int m) {
  n %= mod;
  if (n < m) return 0;
  int pro = 1;
  for (int i = n; i >= n - m + 1; i--) pro = 1ll * pro * i % mod;
  pro = 1ll * pro * ifac[m] % mod;
  return pro;
}
int DP(int g, int n, int k) {
  if (dp[g][n][k] != -1) return dp[g][n][k];
  int &res = dp[g][n][k];
  if (n == 1) return res = (g % (d - 1) == 0);
  if (g == 0) return res = (n == 1);
  if (k == 0) return 0;
  res = 0;
  Add(res, DP(g, n, k - 1));
  if ((k - 1) % (d - 1)) return res;
  int f = DP(d - 1, k, k - 1);
  for (int i = 1; i <= g; i++) {
    if (i * k >= n) break;
    Add(res, 1ll * DP(g - i, n - k * i, k - 1) * binom(f + i - 1, i) % mod);
  }
  return res;
}
void quit(int x) { printf("%d\n", x), exit(0); }
void initmath(int n) {
  ifac[0] = ifac[1] = 1;
  for (int i = 2; i <= n; i++)
    ifac[i] = 1ll * (mod - mod / i) * ifac[mod % i] % mod;
  for (int i = 1; i <= n; i++) ifac[i] = 1ll * ifac[i - 1] * ifac[i] % mod;
  return;
}
int calc(int g, int n, int k) {
  if (n == 1 || n == 2) return 1;
  if (n < g + 1) return 0;
  if ((n - g - 1) % (d - 1) != 0) return 0;
  return DP(g, n, k);
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &n, &d, &mod);
  if (n == 1 || n == 2) quit(1);
  if (n < d + 1) quit(0);
  if ((n - d - 1) % (d - 1) != 0) quit(0);
  initmath(d);
  if (n & 1) quit(DP(d, n, n / 2));
  int ans = DP(d, n, n / 2);
  ans = (ans - binom(DP(d - 1, n / 2, n / 2), 2) + mod) % mod;
  quit(ans);
  return 0;
}
