#include <bits/stdc++.h>
using namespace std;
const long long N = 5e4 + 5, M = 505;
long long lst[N], f[N][M];
long long n, m, cnt, ans;
struct edge {
  long long to, nxt;
} e[N << 1];
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
inline void add(long long u, long long v) {
  e[++cnt].to = v;
  e[cnt].nxt = lst[u];
  lst[u] = cnt;
}
inline void dfs(long long x, long long dad) {
  f[x][0] = 1;
  for (long long i = lst[x]; i; i = e[i].nxt) {
    long long to = e[i].to;
    if (to == dad) continue;
    dfs(to, x);
    for (long long j = 0; j < m; j++) ans += f[to][j] * f[x][m - j - 1];
    for (long long j = 0; j < m; j++) f[x][j + 1] += f[to][j];
  }
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i < n; i++) {
    long long u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  return printf("%lld", ans), 0;
}
