#include <bits/stdc++.h>
const int MN = 50004;
int N, K, hvy[MN], sz[MN], dist[MN], ecnt, ein[MN], eout[MN], eid[MN], arr[MN];
std::vector<int> adj[MN];
long long ans;
inline int qry(int d, int s) {
  if (d < 0 || s + d >= MN) return 0;
  return arr[s + d];
}
void dfs1(int src, int par, int d = 0) {
  sz[src] = 1;
  hvy[src] = -1;
  dist[src] = d;
  eid[ein[src] = ++ecnt] = src;
  for (int i : adj[src]) {
    if (i == par) continue;
    dfs1(i, src, d + 1);
    if (!~hvy[src] || sz[i] > sz[hvy[src]]) hvy[src] = i;
  }
  eout[src] = ecnt;
}
void dfs2(int src, int par, int sum, bool keep) {
  for (int i : adj[src]) {
    if (i == par || i == hvy[src]) continue;
    dfs2(i, src, sum + 1, 0);
  }
  if (~hvy[src]) dfs2(hvy[src], src, sum + 1, 1);
  for (int i : adj[src]) {
    if (i == par || i == hvy[src]) continue;
    for (int j = ein[i]; j <= eout[i]; ++j)
      ans += qry(K - (dist[eid[j]] - sum), sum);
    for (int j = ein[i]; j <= eout[i]; ++j) ++arr[dist[eid[j]]];
  }
  ans += qry(K, sum);
  ++arr[dist[src]];
  if (!keep)
    for (int i = ein[src]; i <= eout[src]; ++i) --arr[dist[eid[i]]];
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1, a, b; i < N; ++i) {
    scanf("%d%d", &a, &b);
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
  }
  dfs1(1, -1);
  dfs2(1, -1, 0, 0);
  printf("%lld", ans);
}
