#include <bits/stdc++.h>
using namespace std;
int dp[50050][505], n, k, m, c;
long long ans = 0;
vector<int> v[50050];
void dfs(int now, int p) {
  dp[now][0] = 1;
  for (int i = 0; i < v[now].size(); i++) {
    int to = v[now][i];
    if (to != p) {
      dfs(to, now);
      for (int j = 0; j < k; j++) ans += (dp[now][j] * dp[to][k - j - 1]);
      for (int j = 0; j < k; j++) dp[now][j + 1] += dp[to][j];
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
