#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int vis[maxn], siz[maxn], s[maxn], q[maxn], rt, rtsiz, sum, n, k, top;
int judge[maxn];
vector<pair<int, int> > g[maxn];
void dfs(int u, int fa) {
  siz[u] = 1;
  int maxsiz = 0;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v == fa || vis[v]) continue;
    dfs(v, u);
    siz[u] += siz[v];
    maxsiz = max(maxsiz, siz[v]);
  }
  maxsiz = max(maxsiz, sum - siz[u]);
  if (maxsiz < rtsiz) {
    rtsiz = maxsiz;
    rt = u;
  }
}
void getdis(int u, int fa, int len) {
  s[++top] = len;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v == fa || vis[v]) continue;
    getdis(v, u, len + g[u][i].second);
  }
}
long long solve(int u, int fa, int len) {
  top = 0;
  getdis(u, fa, len);
  long long tmp = 0;
  int cnt = 0;
  for (int i = 1; i <= top; i++) {
    if (s[i] > k) continue;
    if (judge[k - s[i]]) tmp += judge[k - s[i]];
    judge[s[i]]++;
    q[++cnt] = s[i];
  }
  for (int i = 1; i <= cnt; i++) judge[q[i]] = 0;
  return tmp;
}
long long ans = 0;
void divide(int u) {
  vis[u] = 1;
  ans += solve(u, 0, 0);
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    int w = g[u][i].second;
    if (vis[v]) continue;
    ans -= solve(v, 0, w);
    rt = 0;
    rtsiz = n;
    sum = siz[v];
    dfs(v, 0);
    divide(rt);
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back({v, 1});
    g[v].push_back({u, 1});
  }
  rt = 0;
  rtsiz = sum = n;
  dfs(1, 0);
  divide(rt);
  cout << ans << endl;
  return 0;
}
