#include <bits/stdc++.h>
using namespace std;
int dX[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dY[] = {0, 1, 0, -1, 1, 1, -1, -1};
long long int ans;
long long int n, k;
vector<int> adjList[50007];
long long int dp[505][50007];
void dfs(int cur, int par) {
  for (int i = 0; i < adjList[cur].size(); ++i) {
    if (adjList[cur][i] != par) {
      dfs(adjList[cur][i], cur);
    }
  }
  dp[0][cur] = 1;
  for (int j = 1; j <= 500; ++j) {
    for (int i = 0; i < adjList[cur].size(); ++i) {
      if (adjList[cur][i] != par) {
        dp[j][cur] += dp[j - 1][adjList[cur][i]];
      }
    }
  }
  ans += dp[k][cur];
  long long int tmp = 0;
  for (int lft = 1; lft < k; ++lft) {
    for (int i = 0; i < adjList[cur].size(); ++i) {
      if (adjList[cur][i] != par) {
        tmp += (dp[lft - 1][adjList[cur][i]]) *
               (dp[k - lft][cur] - dp[k - lft - 1][adjList[cur][i]]);
      }
    }
  }
  ans += tmp / 2;
  return;
}
int main() {
  long long int u, v;
  cin >> n >> k;
  for (long long int i = 1; i < n; ++i) {
    cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
  }
  dfs(1, -1);
  cout << ans << endl;
  return 0;
}
