#include <fstream>
#include <vector>
#include <cassert>

using namespace std;

int n, d;
vector <vector <int> > to;

int getC (int v, int p, int d) {
  if (d == 0) {
    return 1;
  }
  int ans = 0;
  for (int i = 0; i < (int)to[v].size (); ++i) {
    int u = to[v][i];
    if (u != p) {
      ans += getC (u, v, d - 1);
    }
  }
  return ans;
}

int main () {
  ifstream fin ("capitals.in");
  assert (fin >> n >> d);
  to = vector <vector <int> > (n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    assert (fin >> a >> b);
    --a;
    --b;
    to[a].push_back (b);
    to[b].push_back (a);
  }
  fin.close ();
  long long ans = 0;
  if (d % 2 == 0) {
    for (int i = 0; i < n; ++i) {
      long long f[4] = {1, 0, 0, 0};
      for (int j = 0; j < (int)to[i].size (); ++j) {
        long long t = getC (to[i][j], i, d / 2 - 1);
        for (int k = 3; k > 0; --k) {
          f[k] += f[k - 1] * t;
        }
      }
      ans += f[3];
    }
  }
  ofstream fout ("capitals.out");
  fout << ans << endl;
  fout.close ();
  return 0;
}
