#include <bits/stdc++.h>
using namespace std;
vector<int> G[50001];
int f[50001][501], k;
long long ans = 0;
void dfs(int vertex, int parent) {
  f[vertex][0] = 1;
  for (auto child : G[vertex]) {
    if (child == parent) continue;
    dfs(child, vertex);
    for (int dist = 1; dist <= k; dist++) {
      f[vertex][dist] += f[child][dist - 1];
    }
  }
  long long soma = 0;
  for (auto child : G[vertex]) {
    if (child == parent) continue;
    for (int i = 1; i < k; i++) {
      if (f[vertex][k - i] == 0) continue;
      soma += f[child][i - 1] * (f[vertex][k - i] - f[child][k - i - 1]);
    }
  }
  ans += soma / 2;
}
int main() {
  ios::sync_with_stdio(false);
  memset(f, 0, sizeof(f));
  int n, u, v;
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(0, -1);
  for (int i = 0; i < n; i++) ans += f[i][k];
  cout << ans << '\n';
  return 0;
}
