#include <bits/stdc++.h>
using namespace std;
bool* taken;
vector<int>* g;
int* depth;
int* subtree;
int n;
void dfs_depth(int node, int p) {
  subtree[node] = 1;
  depth[node] = 1;
  for (int i = 0; i < g[node].size(); i++) {
    int u = g[node][i];
    if (u == p || taken[u]) continue;
    dfs_depth(u, node);
    depth[node] = max(depth[node], depth[u]);
    subtree[node] += subtree[u];
  }
}
int dfsCent(int node, int p, int pr) {
  for (int i = 0; i < g[node].size(); i++) {
    int u = g[node][i];
    if (u == p || taken[u]) continue;
    if (subtree[u] * 2 > (subtree[node] + pr))
      return dfsCent(u, node, subtree[node] - subtree[u] + pr);
  }
  return node;
}
int centroid_(int node) {
  dfs_depth(node, -1);
  return dfsCent(node, -1, 0);
}
long long int ans = 0;
int sum = 0;
long long int* vals;
long long int* temp;
int k;
void dfs(int node, int d, int p) {
  if (d > k) return;
  ans += vals[k - d];
  temp[d]++;
  for (int i = 0; i < g[node].size(); i++) {
    int u = g[node][i];
    if (u == p || taken[u]) continue;
    dfs(u, d + 1, node);
  }
}
void solve(int node) {
  int MXX = k + 2;
  vals = new long long int[MXX];
  temp = new long long int[MXX];
  for (int i = 0; i < MXX; i++) vals[i] = 0;
  vals[0] = 1;
  for (int i = 0; i < g[node].size(); i++) {
    int u = g[node][i];
    if (taken[u]) continue;
    for (int j = 0; j < MXX; j++) temp[j] = 0;
    dfs(u, 1, node);
    for (int j = 0; j < MXX; j++) vals[j] += temp[j];
  }
  taken[node] = 1;
}
int main() {
  cin >> n >> k;
  g = new vector<int>[n];
  subtree = new int[n];
  depth = new int[n];
  taken = new bool[n];
  for (int i = 0; i < n; i++) subtree[i] = depth[i] = taken[i] = 0;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (taken[i]) continue;
    int cen = centroid_(i);
    solve(cen);
    i--;
  }
  cout << ans << endl;
  return 0;
}
