#include <bits/stdc++.h>
using namespace std;
const int N = 50010, M = N + N;
const int K = 505;
int n, m;
int en, hd[N], vo[M], pv[M];
void init() {
  en = 0;
  memset(hd, -1, sizeof hd);
}
void add(int u, int v) {
  vo[en] = v;
  pv[en] = hd[u];
  hd[u] = en++;
}
int f[N][K];
long long ans;
void dfs(int u, int p) {
  f[u][0] = 1;
  for (int z = hd[u]; z > -1; z = pv[z]) {
    int v = vo[z];
    if (v == p) continue;
    dfs(v, u);
    for (int k = 1; k <= m; k++) f[u][k] += f[v][k - 1];
  }
  for (int z = hd[u]; z > -1; z = pv[z]) {
    int v = vo[z];
    if (v == p) continue;
    for (int k = 1; k <= m; k++) {
      ans += f[v][k - 1] *
             (f[u][m - k] - (m - k - 1 >= 0 ? f[v][m - k - 1] : 0)) *
             (k == m ? 2 : 1);
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  init();
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    add(u, v);
    add(v, u);
  }
  memset(f, 0, sizeof f);
  ans = 0;
  dfs(0, -1);
  printf("%I64d\n", ans / 2);
  return 0;
}
