#include <bits/stdc++.h>
using namespace std;
vector<int> G[50010];
int n, k, dp[50010][510], ans = 0;
void DFS(int v, int p) {
  dp[v][0] = 1;
  for (auto u : G[v]) {
    if (u == p) continue;
    DFS(u, v);
    for (int i = 1; i <= k; i++) ans += dp[v][i - 1] * dp[u][k - i];
    for (int i = 1; i <= k; i++) dp[v][i] += dp[u][i - 1];
  }
}
void Solve() {
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  DFS(1, -1);
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    Solve();
  }
  return 0;
}
