#include <bits/stdc++.h>
using namespace std;
const int Max = 50001;
vector<int> edge[Max];
int dp[Max][501];
int n, k;
int dfs(int ro, int fa, int &ans) {
  int dep = 0;
  dp[ro][0] = 1;
  for (int i = 0; i < edge[ro].size(); ++i) {
    if (edge[ro][i] == fa) continue;
    dep = max(dfs(edge[ro][i], ro, ans), dep);
    if (dep > k) dep = k;
    for (int j = 1; j <= k; ++j) ans += dp[ro][j - 1] * dp[edge[ro][i]][k - j];
    for (int j = 1; j <= dep; ++j) dp[ro][j] += dp[edge[ro][i]][j - 1];
  }
  return dep + 1;
}
int main() {
  while (~scanf("%d %d", &n, &k)) {
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < Max; ++i) edge[i].clear();
    for (int i = 0; i < n - 1; ++i) {
      int u, v;
      scanf("%d %d", &u, &v);
      edge[u].push_back(v);
      edge[v].push_back(u);
    }
    int ans = 0;
    dfs(1, -1, ans);
    printf("%d\n", ans);
  }
}
