#include <bits/stdc++.h>
using namespace std;
const int N = 50001;
const int M = 501;
int dp[N][M], lst[N], vf[N * 2], urm[2 * N], nr, ans, k;
void dfs(int x, int pred) {
  dp[x][0] = 1;
  for (int p = lst[x]; p != 0; p = urm[p]) {
    int y = vf[p];
    if (y != pred) {
      dfs(y, x);
      for (int i = 1; i <= k; i++) ans += dp[y][i - 1] * dp[x][k - i];
      for (int i = 1; i <= k; i++) dp[x][i] += dp[y][i - 1];
    }
  }
}
void adauga(int x, int y) {
  vf[++nr] = y;
  urm[nr] = lst[x];
  lst[x] = nr;
}
int main() {
  int n, x, y;
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    adauga(x, y);
    adauga(y, x);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
