#include <bits/stdc++.h>
using namespace std;
struct edge {
  int link, next;
} e[100010];
int n, k, f[50010][510], h[100010], jud[50010], tt = 0;
long long ans[50010], tot;
void addEdge(int x, int y) {
  tt++;
  e[tt].link = y;
  e[tt].next = h[x];
  h[x] = tt;
}
void dfs(int x) {
  jud[x] = 1;
  f[x][0] = 1;
  for (int i = h[x]; i != 0; i = e[i].next)
    if (jud[e[i].link] == 0) {
      int y = e[i].link;
      dfs(y);
      for (int j = 0; j < k; j++)
        ans[x] = ans[x] + 1LL * f[x][j] * f[y][k - j - 1];
      for (int j = 0; j < k; j++) f[x][j + 1] += f[y][j];
    }
  tot += ans[x];
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    addEdge(a, b);
    addEdge(b, a);
  }
  memset(jud, 0, sizeof(jud));
  dfs(1);
  cout << tot << endl;
  return 0;
}
