#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = -1e18;
const long long INF = 1e18;
long long us[N], n, k, x, y, dp[50010][510], ans;
vector<long long> g[N];
void dfs(int v) {
  us[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    if (us[g[v][i]] == 0) {
      dfs(g[v][i]);
      for (int j = 1; j < k; j++) {
        if ((dp[g[v][i]][k - j - 1] > 0 || k - j == 1) && dp[v][j] > 0) {
          ans += dp[g[v][i]][k - j - 1] * dp[v][j];
        }
      }
      for (int j = 1; j <= k; j++) {
        dp[v][j] += dp[g[v][i]][j - 1];
      }
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    ans += dp[i][k];
  }
  cout << ans;
}
