#include <bits/stdc++.h>
using namespace std;
int vis[50005];
long long int dp[50005][505];
int k;
vector<int> v[50005];
long long ans;
void dfs(int i) {
  vis[i] = 1;
  dp[i][0] = 1;
  for (auto j : v[i]) {
    if (!vis[j]) {
      vis[j] = 1;
      dfs(j);
      for (int w = 0; w <= k; w++) ans += dp[i][w] * dp[j][k - w - 1];
      for (int w = 0; w <= k; w++) dp[i][w + 1] += dp[j][w];
    }
  }
}
int main() {
  int n, a, b;
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1);
  cout << ans;
}
