#include <bits/stdc++.h>
using namespace std;
const int INF = (1LL << 31) - 1;
vector<int> adj[50005];
long long cnt[50005][505];
int n, K;
long long res;
void dfs(int i, int prev) {
  cnt[i][0] = 1;
  for (int j = 0; j < adj[i].size(); ++j)
    if (adj[i][j] != prev) {
      dfs(adj[i][j], i);
      for (int k = 0; k < K; ++k) {
        int k1 = K - k - 1;
        res += cnt[i][k] * cnt[adj[i][j]][k1];
      }
      for (int k = 0; k < K; ++k) cnt[i][k + 1] += cnt[adj[i][j]][k];
    }
}
int main() {
  res = 0;
  scanf("%d %d", &n, &K);
  int u, v;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(cnt, 0, sizeof(cnt));
  dfs(1, -1);
  cout << res << endl;
  return 0;
}
