#include <bits/stdc++.h>
using namespace std;
const int N = 50010;
const int inf = 1e9 + 7;
int n, k;
vector<int> g[N];
long long sum[510], cnt[N][510], ans;
void DP(int u, int fa) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v == fa) continue;
    DP(v, u);
  }
  memset(sum, 0, sizeof sum);
  sum[0] = 1;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    if (v == fa) continue;
    for (int j = k - 1; j >= 0; --j) {
      if (cnt[v][j] > 0) cnt[u][j + 1] += cnt[v][j];
      ans += cnt[v][j] * sum[k - j - 1];
    }
    for (int j = 0; j < k; ++j) sum[j + 1] += cnt[v][j];
  }
  cnt[u][0] = 1;
}
void Run() {
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i <= n; ++i) g[i].clear();
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  ans = 0;
  DP(1, -1);
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int _, cas = 1;
  while (cin >> n >> k) Run();
}
