#include <bits/stdc++.h>
using namespace std;
const long long MXN = 5e4 + 10;
const long long MXM = 5e2 + 10;
const long long MX5 = 2e5 + 10;
const long long MX6 = 1e6 + 10;
const long long INF = 8e18;
const long double eps = 1e-9;
const long long MOD = 1e9 + 7;
long long power(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * power(a * a % md, b / 2, md) % md
                      : power(a * a % md, b / 2, md) % md));
}
long long bmm(long long a, long long b) {
  return (a % b == 0 ? b : bmm(b, a % b));
}
string base2(long long n) {
  string a = "";
  while (n >= 2) {
    a += (char)(n % 2 + '0');
    n /= 2;
  }
  a += (char)(n + '0');
  reverse((a).begin(), (a).end());
  return a;
}
long long n, k, kp, ans, dis[MXN][MXM], par[MXN];
vector<long long> G[MXN];
bool vis[MXN];
void DFS(long long u) {
  vis[u] = 1;
  dis[u][0] = 1;
  for (auto v : G[u]) {
    if (!vis[v]) {
      DFS(v);
      par[v] = u;
      if (k > 1) {
        for (int i = 0; i <= k - 2; i++) {
          ans += dis[v][i] * dis[u][k - 2 - i + 1];
        }
      }
      for (int i = 1; i <= k; i++) {
        dis[u][i] += dis[v][i - 1];
      }
    }
  }
  ans += dis[u][k];
  return;
}
int main() {
  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);
  }
  DFS(1);
  cout << ans;
  return 0;
}
