#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 50000 + 10;
const int KK = 500 + 10;
int n, K, i, k, j, x[N], y[N], de[N][2], dv[N][KK], u[N];
long long res, tmp;
int main() {
  scanf("%d%d", &n, &K);
  for (j = 1; j < n; j++) {
    scanf("%d%d", &x[j], &y[j]);
    x[n - 1 + j] = y[j];
    y[n - 1 + j] = x[j];
    u[n - 1 + j] = j;
    u[j] = n - 1 + j;
  }
  for (j = 1; j < 2 * n; j++) {
    de[j][1] = 1;
    dv[x[j]][1]++;
  }
  for (k = 1; k < K; k++)
    for (j = 1; j < 2 * n; j++) {
      de[j][(k + 1) % 2] = dv[y[j]][k] - de[u[j]][k % 2];
      dv[x[j]][k + 1] += de[j][(k + 1) % 2];
    }
  for (i = 1; i <= n; i++) {
    tmp = dv[i][K];
    res += tmp;
  }
  cout << res / 2LL << endl;
}
