#include <bits/stdc++.h>
using namespace std;
long long ans = 0, n, a, b, k, dis[50010][510];
std::vector<long long> v[50010];
void dfs(int u, int p) {
  dis[u][0] = 1;
  for (int i = 0; i < v[u].size(); i++) {
    if (v[u][i] == p) continue;
    dfs(v[u][i], u);
    for (int j = 0; j < k; j++) {
      ans = ans + dis[v[u][i]][j] * dis[u][k - j - 1];
    }
    for (int j = 1; j <= k; j++) {
      dis[u][j] = dis[u][j] + dis[v[u][i]][j - 1];
    }
  }
}
int main() {
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    scanf("%lld%lld", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0);
  printf("%lld\n", ans);
  return 0;
}
