#include <bits/stdc++.h>
using namespace std;
vector<int> vi[50050];
int dp[50050][505];
long long chaeng;
int k;
void dfs(int now, int prev) {
  dp[now][0] = 1;
  for (auto x : vi[now]) {
    if (x == prev) continue;
    dfs(x, now);
    dp[now][1]++;
    for (int i = 2; i <= k; i++) {
      dp[now][i] += dp[x][i - 1];
    }
  }
  chaeng += dp[now][k];
  long long sum = 0;
  for (auto x : vi[now]) {
    if (x == prev) continue;
    for (int i = 1; i < k; i++) {
      sum += 1LL * dp[x][i - 1] * (dp[now][k - i] - dp[x][k - i - 1]);
    }
  }
  sum /= 2;
  chaeng += sum;
}
int main() {
  int n, i, j, x, y, ans, curr, temp, m;
  cin >> n >> k;
  if (k == 1) {
    cout << n - 1 << endl;
    return 0;
  }
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    vi[x].push_back(y);
    vi[y].push_back(x);
  }
  chaeng = 0;
  dfs(1, 0);
  cout << chaeng << endl;
  return 0;
}
