#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
const int MAXN = 5e4 + 5;
const int MAXK = 510;
vector<int> way[MAXN];
int N, K;
long long ans;
vector<long long> f(int node, int pre) {
  vector<long long> res(MAXK, 0);
  res[0] = 1LL;
  for (int(i) = (0); (i) < (way[node].size()); (i)++)
    if (way[node][i] != pre) {
      vector<long long> v = f(way[node][i], node);
      vector<long long> eski = res;
      for (int(j) = (0); (j) < (K); (j)++) {
        if (j + 1 <= K) ans += eski[K - (j + 1)] * v[j];
        if (j + 1 < MAXK) res[j + 1] += v[j];
      }
    }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> K;
  for (int(i) = (1); (i) <= (N - 1); (i)++) {
    int a, b;
    cin >> a >> b;
    way[a].push_back(b);
    way[b].push_back(a);
  }
  f(1, -1);
  cout << ans << endl;
  return 0;
}
