#include <bits/stdc++.h>
using namespace std;
long long n, k;
vector<long long> g[100100];
bool cnt[100100];
bool used[100100];
long long dp[100100];
long long w[100100];
long long ww[100100];
long long tt;
long long dfs(int v, int p) {
  dp[v] = 0;
  tt++;
  for (int i = 0; i < g[v].size(); i++) {
    long long to = g[v][i];
    if (to != p && !cnt[to]) {
      dp[v] += dfs(to, v);
    }
  }
  dp[v]++;
  return dp[v];
}
long long findCentroid(int v, int p) {
  long long mmax = 0;
  long long nnext = -1;
  for (int i = 0; i < g[v].size(); i++) {
    long long to = g[v][i];
    if (to != p && !cnt[to]) {
      if (dp[to] > mmax) {
        mmax = dp[to];
        nnext = to;
      }
    }
  }
  if (tt / 2 < mmax && nnext != -1) {
    return findCentroid(nnext, v);
  } else {
    return v;
  }
}
long long StartfindCentroid(int v) {
  tt = 0;
  dfs(v, -1);
  long long c = findCentroid(v, -1);
  return c;
}
void solve(long long v, long long kk, long long p) {
  if (kk > k) return;
  w[kk]++;
  for (int i = 0; i < g[v].size(); i++) {
    long long to = g[v][i];
    if (to != p && !cnt[to]) {
      solve(to, kk + 1, v);
    }
  }
}
long long sol = 0;
void Stsolve(long long v) {
  cnt[v] = 1;
  long long mmaxk = 0;
  for (int i = 0; i < g[v].size(); i++) {
    long long to = g[v][i];
    if (!cnt[to]) {
      solve(to, 1, v);
      for (int i = 1; i < k; i++) {
        if (w[i] == 0) break;
        mmaxk = max(mmaxk, k);
        sol += (w[i] * ww[k - i]);
      }
      for (int i = 1; i < k; i++) {
        if (w[i] == 0) break;
        ww[i] += w[i];
        w[i] = 0;
      }
      sol += w[k];
      w[k] = 0;
    }
  }
  for (int i = 0; i <= mmaxk + 1; i++) {
    ww[i] = 0;
  }
  ww[k] = 0;
  for (int i = 0; i < g[v].size(); i++) {
    long long to = g[v][i];
    if (!cnt[to]) {
      long long c = StartfindCentroid(to);
      Stsolve(c);
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  long long c = StartfindCentroid(1);
  Stsolve(c);
  cout << sol << endl;
  return 0;
}
