#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
vector<int> g[50505];
long long dp[50505][555];
int n, k;
bool used[50505];
long long res;
void dfs(int ver, int pref) {
  used[ver] = true;
  for (int i = 0; i < g[ver].size(); i++) {
    int to = g[ver][i];
    if (pref == to) continue;
    dfs(to, ver);
    for (int j = 1; j <= k; j++) dp[ver][j] += dp[to][j - 1];
  }
}
void dfs_res(int ver, int pref) {
  res += dp[ver][k] * 2;
  for (int i = 0; i < g[ver].size(); i++) {
    int to = g[ver][i];
    if (pref == to) continue;
    dfs_res(to, ver);
    bool flag = true;
    for (int j = 1; j <= k - 1; j++)
      res += dp[to][k - j - 1] * (dp[ver][j] - dp[to][j - 1]);
  }
}
int main() {
  cin >> n >> k;
  memset(used, false, sizeof used);
  for (int i = 1; i <= n; i++) dp[i][0] = 1;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, -1);
  dfs_res(1, -1);
  cout << res / 2 << endl;
  return 0;
}
