#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100001];
int n;
int k;
long long ans;
vector<int> dfs(int node, int parent = -1) {
  vector<int> fake(k + 1, 0);
  fake[0] = 1;
  for (auto it : adj[node]) {
    if (it == parent) continue;
    vector<int> now = dfs(it, node);
    for (int i = 0; i <= k; i++)
      ans += (long long)fake[i] * (long long)now[k - i];
    for (int i = 0; i <= k; i++) fake[i] += now[i];
  }
  for (int i = k; i >= 1; i--) {
    fake[i] = fake[i - 1];
  }
  fake[0] = 0;
  return fake;
}
void solve() {
  cin >> n;
  cin >> k;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1);
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
