#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> g[n + 1];
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<vector<int>> dp(n + 1, vector<int>(k + 1));
  int ans = 0;
  function<void(int, int)> dfs;
  dfs = [&](int u, int pre) {
    dp[u][0] = 1;
    for (auto v : g[u]) {
      if (v != pre) {
        dfs(v, u);
        for (int j = 0; j < k; ++j) {
          ans += dp[v][j] * dp[u][k - 1 - j];
        }
        for (int j = 1; j <= k; ++j) {
          dp[u][j] += dp[v][j - 1];
        }
      }
    }
  };
  dfs(1, 0);
  cout << ans << '\n';
  return 0;
}
