#include <bits/stdc++.h>
using namespace std;
const int N = 50003, K = 503;
int cnt[K][N];
vector<int> g[N];
long long ans = 0, pans = 0;
int k;
void dfs(int v, int p = -1) {
  cnt[0][v] = 1;
  for (int to : g[v]) {
    if (to != p) {
      dfs(to, v);
      for (int d = 1; d < K; d++) {
        cnt[d][v] += cnt[d - 1][to];
      }
    }
  }
  for (int to : g[v]) {
    if (to == p) continue;
    for (int d = 1; d < k; d++) {
      ans += 1ll * cnt[d - 1][to] * (cnt[k - d][v] - cnt[k - d - 1][to]);
    }
  }
  pans += cnt[k][v];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0);
  cout << ans / 2 + pans;
  return 0;
}
