#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
vector<int> Adj[maxn];
int n, k;
long long res = 0;
bool visited[maxn];
void Input() {
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    Adj[u].push_back(v);
    Adj[v].push_back(u);
  }
}
vector<int> DFS(int u) {
  vector<int> t(k + 1);
  visited[u] = true;
  t[0] = 1;
  for (int v : Adj[u])
    if (!visited[v]) {
      vector<int> s = DFS(v);
      for (int i = 0; i <= k; i++) res += t[i] * (long long)s[k - i];
      for (int i = 0; i <= k; i++) t[i] += s[i];
    }
  for (int i = k; i >= 1; i--) t[i] = t[i - 1];
  t[0] = 0;
  return t;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  fill(visited + 1, visited + 1 + n, false);
  Input();
  DFS(1);
  cout << res;
}
