#include <bits/stdc++.h>
using namespace std;
const long long siz = 5e4 + 2;
const long long SIZ = 5e2 + 2;
const long long mod = 1e9 + 7;
const long long maxx = 2e9;
const long long MAXX = 1e18;
const string file = "3";
long long k;
vector<vector<long long> > adj_list;
long long f[siz][SIZ];
long long ans;
void dfs(long long u, long long p) {
  f[u][0] = 1;
  for (auto v : adj_list[u]) {
    if (v == p) {
      continue;
    }
    dfs(v, u);
    for (long long i = 1; i <= k; i++) {
      ans += f[u][i - 1] * f[v][k - i];
    }
    for (long long i = 1; i <= k; i++) {
      f[u][i] += f[v][i - 1];
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n >> k;
  adj_list.resize(n + 1);
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj_list[u].push_back(v);
    adj_list[v].push_back(u);
  }
  dfs(1, 0);
  cout << ans << "\n";
  return 0;
}
