#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
const int M = 510;
int n, k, dp[N][M];
long long ans;
vector<int> edge[N];
void addedge(int u, int v) {
  edge[u].push_back(v);
  edge[v].push_back(u);
}
void dfs(int u, int f) {
  dp[u][0] = 1;
  for (int i = 0; i < (int)edge[u].size(); ++i) {
    int v = edge[u][i];
    if (v == f) continue;
    dfs(v, u);
    for (int j = 0; j < k; ++j) {
      ans += 1ll * dp[u][j] * dp[v][k - j - 1];
    }
    for (int j = 1; j <= k; ++j) {
      dp[u][j] += dp[v][j - 1];
    }
  }
}
int main(void) {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    addedge(u, v);
  }
  dfs(1, 0);
  cout << ans << endl;
  return 0;
}
