#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int32_t mod = 1000000007;
const long long N = 50000 + 5;
long long n, k;
vector<long long> gr[N];
long long dp[N][505], ans = 0;
long long dfs(long long node, long long par) {
  for (auto& i : gr[node]) {
    if (i == par) continue;
    dfs(i, node);
  }
  for (auto& i : gr[node]) {
    if (i == par) continue;
    for (long long la = 0; la < 504; la++) {
      dp[node][la + 1] += dp[i][la];
    }
  }
  dp[node][0] += 1;
  return 0;
}
long long dfs2(long long node, long long par) {
  long long ans2 = 0;
  ans += dp[node][k];
  for (long long l = 1; l <= k - 1; l++) {
    for (auto& i : gr[node]) {
      if (i == par) continue;
      long long x = (dp[i][l - 1] * (dp[node][k - l] - dp[i][k - l - 1]));
      ans2 += x;
    }
  }
  for (auto& i : gr[node]) {
    if (i == par) continue;
    dfs2(i, node);
  }
  ans2 /= 2;
  ans += ans2;
  return 0;
}
long long solve() {
  cin >> n >> k;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  dfs(1, -1);
  dfs2(1, -1);
  cout << ans << '\n';
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  long long tests = 1;
  for (long long i = 1; i <= tests; i++) {
    solve();
  }
  return 0;
}
