#include <bits/stdc++.h>
using namespace std;
int f[50001][501], k, ans;
vector<int> t[50001];
void dfs(int u, int pre) {
  f[u][0] = 1;
  int i, j, v;
  for (i = 0; i < t[u].size(); i++) {
    v = t[u][i];
    if (v == pre) continue;
    dfs(v, u);
    for (j = 1; j <= k; j++) ans += f[u][j - 1] * f[v][k - j];
    for (j = 1; j <= k; j++) f[u][j] += f[v][j - 1];
  }
}
int main() {
  int n, a, b, i;
  ans = 0;
  cin >> n >> k;
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  dfs(1, -1);
  cout << ans << endl;
  return 0;
}
