#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long n, k;
vector<long long int> v[50005];
long long ans;
vector<long long int> dfs(long long node, long long par) {
  vector<long long int> temp(k + 1);
  temp[0] = 1;
  for (auto i : v[node]) {
    if (i != par) {
      vector<long long int> cc = dfs(i, node);
      for (long long i = 0; i <= k; i++) ans += cc[i] * temp[k - i];
      for (long long i = 0; i <= k; i++) temp[i] += cc[i];
    }
  }
  for (long long i = k; i >= 1; i--) temp[i] = temp[i - 1];
  temp[0] = 0;
  return temp;
}
void solve() {
  cin >> n >> k;
  for (long long i = 1; i <= n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  ans = 0;
  dfs(1, -1);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
