#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

const int N = 444444;

int CNT[2*N], *cnt = CNT+N;

vector <int> g[N];
int ss[N], ff[N], pred[N], last[N], was[N];
int kw, w[N], real[N], de[N], st[N], fin[N], n, m, i, d;
long long ans;

void build(int v, int depth) {
  w[++kw] = v;
  real[v] = depth;
  g[depth].push_back(kw);
  st[v] = kw;
  was[v] = 1;
  de[v] = 0;
  int j = last[v];
  while (j > 0) {
    if (!was[ff[j]]) {
      build(ff[j], depth+1);
      if (de[ff[j]]+1 > de[v]) de[v] = de[ff[j]]+1;
    }
    j = pred[j];
  }
  fin[v] = kw;
}

int a[N], la[N], ra[N];

void go(int v, int depth) {
  was[v] = 1;
  int j = last[v], big = 0, who = 0, ka = 0;
  while (j > 0) {
    if (!was[ff[j]]) {
      int ll = 0, rr = g[depth+d].size(), mid;
      while (ll < rr) {
        mid = (ll+rr) >> 1;
        if (g[depth+d][mid] < st[ff[j]]) ll = mid+1;
        else rr = mid;
      }
      int lower = ll;
      ll = -1, rr = g[depth+d].size()-1;
      while (ll < rr) {
        mid = (ll+rr+1) >> 1;
        if (g[depth+d][mid] > fin[ff[j]]) rr = mid-1;
        else ll = mid;
      }
      int upper = ll;
      if (lower <= upper) a[ka++] = upper-lower+1;
      if (de[ff[j]] >= d) big++, who = ff[j];
    }
    j = pred[j];
  }
  if (cnt[d-depth] > 0) a[ka++] = cnt[d-depth];
  if (ka >= 3) {
    la[0] = 0;
    for (i=1;i<ka;i++) la[i] = la[i-1]+a[i-1];
    ra[ka-1] = 0;
    for (i=ka-2;i>=0;i--) ra[i] = ra[i+1]+a[i+1];
    for (i=1;i<ka-1;i++) ans += (long long)a[i]*la[i]*ra[i];
  }
  if (big == 1) {
    int x = st[v];
    while (x <= fin[v]) {
      if (w[x] == who) {
        x = fin[w[x]]+1;
        continue;
      }
      cnt[(real[w[x]]-depth)-depth]++;
      if (real[w[x]]-depth >= d) x = fin[w[x]];
      x++;
    }
    go(who, depth+1);
    x = st[v];
    while (x <= fin[v]) {
      if (w[x] == who) {
        x = fin[w[x]]+1;
        continue;
      }
      cnt[(real[w[x]]-depth)-depth]--;
      if (real[w[x]]-depth >= d) x = fin[w[x]];
      x++;
    }
  } else
  if (big > 1) {
    int x = st[v];
    while (x <= fin[v]) {
      cnt[(real[w[x]]-depth)-depth]++;
      if (real[w[x]]-depth >= d) x = fin[w[x]];
      x++;
    }
    j = last[v];
    while (j > 0) {
      if (!was[ff[j]] && de[ff[j]] >= d) {
        x = st[ff[j]];
        while (x <= fin[ff[j]]) {
          cnt[(real[w[x]]-depth)-depth]--;
          if (real[w[x]]-depth >= d) x = fin[w[x]];
          x++;
        }
        go(ff[j], depth+1);
        x = st[ff[j]];
        while (x <= fin[ff[j]]) {
          cnt[(real[w[x]]-depth)-depth]++;
          if (real[w[x]]-depth >= d) x = fin[w[x]];
          x++;
        }
      }
      j = pred[j];
    }
    x = st[v];
    while (x <= fin[v]) {
      cnt[(real[w[x]]-depth)-depth]--;
      if (real[w[x]]-depth >= d) x = fin[w[x]];
      x++;
    }
  }
}

int main() {
  freopen("capitals.in", "r", stdin);
  freopen("capitals.out", "w", stdout);
  scanf("%d %d", &n, &d);
  if (d & 1) {
    printf("%d\n", 0);
    return 0;
  }
  d /= 2;
  m = n-1;
  for (i=1;i<=m;i++) {
    scanf("%d %d", ss+i, ff+i);
    ss[i+m] = ff[i];
    ff[i+m] = ss[i];
  }
  for (i=1;i<=n;i++) last[i] = 0;
  for (i=1;i<=m+m;i++) {
    pred[i] = last[ss[i]];
    last[ss[i]] = i;
  }
  for (i=1;i<=n;i++) was[i] = 0;
  kw = 0;
  build(1, 0);
  for (i=1;i<=n;i++) was[i] = 0;
  ans = 0;
  go(1, 0);
  cout << ans << endl;
  return 0;
}
