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