#include <bits/stdc++.h>
using namespace std;
const long long N = 5e4 + 1;
const long long K = 500 + 1;
long long n, k, parent[N];
vector<long long> g[N];
long long dp[N][K];
long long ans = 0;
void dfs(long long v, long long p) {
  long long tmp = 0;
  dp[v][0] = 1;
  for (auto x : g[v]) {
    if (x != p) {
      dfs(x, v);
      for (long long i = 0; i < k; i++) {
        ans += dp[v][i] * dp[x][k - i - 1];
      }
      for (long long i = 1; i <= k; i++) {
        dp[v][i] += dp[x][i - 1];
      }
    }
  }
}
int main() {
  cin >> n >> k;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    parent[v] = u;
  }
  dfs(1, -1);
  cout << ans << '\n';
}
