#include <bits/stdc++.h>
using namespace std;
int dp[50000 + 10][500 + 10];
vector<int> grav[50000 + 10];
int parent[50000 + 10];
void dfs(int v, int par) {
  parent[v] = par;
  for (int i = 0; i < (int)grav[v].size(); i++) {
    int to = grav[v][i];
    if (to == par) continue;
    dfs(to, v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  vector<pair<pair<int, int>, int> > evs;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < (int)(n - 1); i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    grav[u].push_back(v);
    grav[v].push_back(u);
  }
  dfs(0, -1);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)grav[i].size(); j++) {
      if (grav[i][j] != parent[i]) {
        ++dp[i][1];
      }
    }
  }
  for (int kk = 1; kk <= k; ++kk) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)grav[i].size(); j++) {
        int to = grav[i][j];
        if (to == parent[i]) continue;
        dp[i][kk] += dp[to][kk - 1];
      }
    }
  }
  for (int i = 0; i < (int)(n); i++) dp[i][0] = 1;
  long long res = 0;
  for (int i = 0; i < (int)(n); i++) {
    int v = i;
    for (int j = 1; j <= k; ++j) {
      int rest = k - j;
      int u = parent[v];
      if (u == -1) break;
      res += dp[u][rest];
      if (rest) {
        res -= dp[v][rest - 1];
      }
      v = u;
    }
  }
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)grav[i].size(); j++) {
      if (grav[i][j] == parent[i]) continue;
      res += dp[grav[i][j]][k - 1];
    }
  }
  cout << res / 2;
  return 0;
}
