#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long gcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  long long g = gcd(b, a % b, x1, y1);
  x = y1;
  y1 = x1 - y1 * (a / b);
  return g;
}
long long qpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % MOD;
      n--;
    } else {
      n = n / 2;
      a = (a * a) % MOD;
    }
  }
  return res;
}
long long inv(long long a) { return qpow(a, MOD - 2); }
bool cmp(pair<long long, long long> &p1, pair<long long, long long> &p2) {
  if (p1.second != p2.second) return p1.second < p2.second;
  return p1.first < p2.first;
}
bool prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void dfs1(vector<vector<int>> &list, vector<int> &vis, int node,
          vector<vector<int>> &depth, vector<int> &par) {
  int n = list.size() - 1;
  int k = depth[1].size() - 1;
  vis[node] = 1;
  for (int j = 0; j < list[node].size(); j++) {
    if (vis[list[node][j]] == 0) {
      par[list[node][j]] = node;
      dfs1(list, vis, list[node][j], depth, par);
      for (int h = 0; h < k; h++) {
        if (depth[list[node][j]][h] > 0)
          depth[node][h + 1] += depth[list[node][j]][h];
      }
    }
  }
  depth[node][0]++;
}
void dfs2(vector<vector<int>> &list, vector<int> &vis, int node,
          vector<vector<int>> &depth, vector<vector<int>> &ans,
          vector<int> &par) {
  int n = list.size() - 1;
  int k = depth[1].size() - 1;
  vis[node] = 1;
  for (int h = 0; h <= k; h++) ans[node][h] = depth[node][h];
  if (node != 1) {
    for (int h = 1; h <= k; h++)
      ans[node][h] += ans[par[node]][h - 1] - (h > 1 ? depth[node][h - 2] : 0);
  }
  for (int j = 0; j < list[node].size(); j++) {
    if (vis[list[node][j]] == 0)
      dfs2(list, vis, list[node][j], depth, ans, par);
  }
}
void solve() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  vector<vector<int>> list(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    list[u].push_back(v);
    list[v].push_back(u);
  }
  vector<vector<int>> depth(n + 1, vector<int>(k + 1)),
      ans(n + 1, vector<int>(k + 1));
  vector<int> vis(n + 1), par(n + 1);
  dfs1(list, vis, 1, depth, par);
  for (int i = 0; i < vis.size(); i++) vis[i] = 0;
  dfs2(list, vis, 1, depth, ans, par);
  long long res = 0;
  for (int i = 1; i <= n; i++) res += ans[i][k];
  cout << res / 2 << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
