#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 99;
multiset<long long> vec[MAX];
long long N, K, X, Y, res, sz, size[MAX], cnt[MAX];
void init(long long node, long long par) {
  size[node] = 1;
  for (auto A : vec[node]) {
    if (A == par) continue;
    init(A, node);
    size[node] += size[A];
  }
  return;
}
long long FindCentroid(long long node, long long par) {
  for (auto A : vec[node]) {
    if (A == par) continue;
    if (size[A] > sz / 2) return FindCentroid(A, node);
  }
  return node;
}
void cal(long long node, long long par, long long hei) {
  if (hei <= K) res += cnt[K - hei];
  for (auto A : vec[node]) {
    if (A == par) continue;
    cal(A, node, hei + 1);
  }
  return;
}
void cal_(long long node, long long par, long long hei, long long delta) {
  cnt[hei] += delta;
  for (auto A : vec[node]) {
    if (A == par) continue;
    cal_(A, node, hei + 1, delta);
  }
  return;
}
void dfs(long long node) {
  long long Node;
  init(node, 0);
  sz = size[node];
  Node = FindCentroid(node, 0);
  cnt[0] = 1;
  for (auto A : vec[Node]) cal(A, Node, 1), cal_(A, Node, 1, 1);
  for (auto A : vec[Node]) cal_(A, Node, 1, -1);
  for (auto A : vec[Node]) vec[A].erase(vec[A].find(Node));
  for (auto A : vec[Node]) dfs(A);
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for (long long A = 1; A < N; A++) {
    cin >> X >> Y;
    vec[X].insert(Y);
    vec[Y].insert(X);
  }
  dfs(1);
  cout << res;
  return 0;
}
