#include <bits/stdc++.h>
using namespace std;
int n, d;
long long int modulo;
int n2;
long long int eleva(long long int b, long long int e) {
  if (e == 0) return 1;
  if (e % 2 == 0) return eleva(b * b % modulo, e / 2);
  return b * eleva(b * b % modulo, e / 2) % modulo;
}
long long int inverso(long long int x) { return eleva(x, modulo - 2); }
void anyade(long long int &a, long long int b) { a = (a + b) % modulo; }
bool puede(int n) {
  if (n == 0) return false;
  return (n - 1) % (d - 1) == 0;
}
long long int elecciones(int n, int ndown, int a);
long long int memmaner[1001];
int calcul[1001];
long long int maner(int n) {
  if (n == 1) return 1;
  long long int &mem = memmaner[n];
  if (calcul[n]) return mem;
  calcul[n] = 1;
  mem = elecciones(n - 1, n - 1, d - 1);
  return mem;
}
long long int memcombi[1001][11];
long long int calccombi[1001][11];
long long int combi(int n, int a) {
  long long int &mem = memcombi[n][a];
  if (calccombi[n][a]) return mem;
  calccombi[n][a] = 1;
  if (a == 0) {
    mem = 1;
    return mem;
  }
  if (not puede(n)) return mem;
  long long int man = maner(n) - 1 + a;
  long long int num = 1;
  long long int div = 1;
  for (int i = 1; i <= a; i++) {
    num = num * (man - i + 1) % modulo;
    div = div * i % modulo;
  }
  mem = num * inverso(div) % modulo;
  return mem;
}
long long int memelecciones[1001][1001][11];
int calcelec[1001][1001][11];
long long int elecciones(int n, int ndown, int a) {
  if (a == 0) return n == 0;
  if (n == 0 or ndown == 0) return 0;
  long long int &mem = memelecciones[n][ndown][a];
  if (calcelec[n][ndown][a]) return mem;
  calcelec[n][ndown][a] = 1;
  for (int aa = 0, suma = 0; aa <= a and suma <= n; aa++, suma += ndown)
    anyade(mem, combi(ndown, aa) *
                    elecciones(n - suma, min(n - suma, ndown - 1), a - aa));
  return mem;
}
int main() {
  cin >> n >> d >> modulo;
  long long int sol = 0;
  if (n % 2 == 0) anyade(sol, combi(n / 2, 2));
  n2 = n / 2;
  if (2 * n2 == n) n2--;
  if (n == 1)
    anyade(sol, 1);
  else
    anyade(sol, elecciones(n - 1, n2, d));
  sol = ((sol % modulo) + modulo) % modulo;
  cout << sol << endl;
}
