#include <bits/stdc++.h>
using namespace std;
const int N = 1007, D = 11, C = 20;
int M, dd, mod;
int dp[N][N][D];
int rev[C];
long long power(int a, int b) {
  if (b == 0) return 1;
  long long res = power(a, b / 2);
  res *= res, res %= mod;
  if (b & 1) res *= a, res %= mod;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> M >> dd >> mod;
  if (M <= 2) return cout << 1 << endl, 0;
  if (dd == 2) return cout << 1 << endl, 0;
  if ((M - 2) % (dd - 1) != 0) return cout << 0 << endl, 0;
  int n = (M - 2) / (dd - 1);
  for (int i = 0; i < C; i++) rev[i] = power(i, mod - 2);
  for (int i = 0; i <= dd; i++) {
    dp[1][0][i] = 1;
    for (int j = 1; j < N; j++) dp[1][j][i] = 1;
  }
  for (int a = 2; a <= n; a++)
    for (int x = 1; x < N; x++)
      for (int d = 1; d < D; d++) {
        dp[a][x][d] = dp[a][x - 1][d];
        long long comb = dp[x][x - 1][dd - 1], t = dp[x][x - 1][dd - 1];
        for (int c = 1; c * x < a && d >= c; c++) {
          long long way = dp[a - c * x][x - 1][d - c];
          way *= comb;
          way %= mod;
          dp[a][x][d] += way, dp[a][x][d] %= mod;
          comb *= (c + t) % mod, comb %= mod, comb *= rev[c + 1], comb %= mod;
        }
      }
  long long t1 = dp[n][(n - 1) / 2][dd];
  if (n & 1) return cout << t1 << endl, 0;
  long long t2 = (1LL * dp[n / 2][n / 2 - 1][dd - 1] *
                  (dp[n / 2][n / 2 - 1][dd - 1] + 1) % mod) *
                 rev[2] % mod;
  t1 += t2, t1 %= mod;
  cout << t1 << endl;
}
