#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;
using namespace std;
inline long long read();
vector<int> g[50010];
int n, k;
long long dp[50010][510];
long long ans = 0;
void dfs(int u, int fa) {
  dp[u][0] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    dfs(v, u);
    for (int i = 0; i < k; i++) {
      ans += dp[u][i] * dp[v][k - 1 - i];
      if (i) dp[u][i] += dp[v][i - 1];
    }
  }
}
int main() {
  n = read(), k = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 0);
  cout << ans;
  return 0;
}
inline long long read() {
  long long p = 1, ans = 0;
  char ch = getchar();
  while (ch < 48 || ch > 57) {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= 48 && ch <= 57) {
    ans = (ans << 3) + (ans << 1) + ch - 48;
    ch = getchar();
  }
  return ans * p;
}
