#include <bits/stdc++.h>
inline int getint() {
  int x = 0, p = 1;
  char c;
  c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int maxn = 1e5 + 5;
vector<int> G[maxn];
bool is_centroid[maxn];
int n, m, res, ison[maxn], ds[505], tds[505];
int cnt_son(int x, int p) {
  int ans = 1;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    ans += cnt_son(to, x);
  }
  return ison[x] = ans;
}
inline int cnt_pairs(vector<int> &ds) {
  int j = ds.size(), ans = 0;
  sort(ds.begin(), ds.end());
  for (int(i) = 0; (i) < (ds.size()); (i)++) {
    while (j > 0 && ds[i] + ds[j - 1] > m) j--;
    ans += j - ((j > i) ? 1 : 0);
  }
  return ans / 2;
}
void enumerate_paths(int x, int p, int len) {
  tds[len]++;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    if (len + 1 <= m) enumerate_paths(to, x, len + 1);
  }
}
pair<int, int> get_centroid(int x, int p, int tot) {
  pair<int, int> ans = make_pair(1000000000, 0);
  int c = 0, ileft = 1;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    ans = min(ans, get_centroid(to, x, tot));
    c = max(c, ison[to]);
    ileft += ison[to];
  }
  c = max(c, tot - ileft);
  ans = min(ans, make_pair(c, x));
  return ans;
}
void work(int x) {
  cnt_son(x, -1);
  int s = get_centroid(x, -1, ison[x]).second;
  is_centroid[s] = true;
  for (int(i) = 0; (i) < (G[s].size()); (i)++) {
    int to = G[s][i];
    if (is_centroid[to]) continue;
    work(to);
  }
  memset(ds, 0, sizeof(ds));
  ds[0]++;
  for (int(i) = 0; (i) < (G[s].size()); (i)++) {
    int to = G[s][i];
    if (is_centroid[to]) continue;
    memset(tds, 0, sizeof(tds));
    enumerate_paths(to, s, 1);
    for (int(j) = 0; (j) < (m + 1); (j)++) res += tds[j] * ds[m - j];
    for (int(j) = 0; (j) < (m + 1); (j)++) ds[j] += tds[j];
  }
  is_centroid[s] = false;
}
int main() {
  n = getint();
  m = getint();
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    int x, y;
    x = getint();
    y = getint();
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  work(0);
  printf("%d\n", res);
  return 0;
}

### Prompt

Your task is to create a CPP solution to the following problem:

A tree is a connected graph that doesn't contain any cycles.

The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.

You are given a tree with n vertices and a positive number k. Find the number of distinct pairs of the vertices which have a distance of exactly k between them. Note that pairs (v, u) and (u, v) are considered to be the same pair.

Input

The first line contains two integers n and k (1 ≤ n ≤ 50000, 1 ≤ k ≤ 500) — the number of vertices and the required distance between the vertices.

Next n - 1 lines describe the edges as "ai bi" (without the quotes) (1 ≤ ai, bi ≤ n, ai ≠ bi), where ai and bi are the vertices connected by the i-th edge. All given edges are different.

Output

Print a single integer — the number of distinct pairs of the tree's vertices which have a distance of exactly k between them.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

5 2
1 2
2 3
3 4
2 5


Output

4


Input

5 3
1 2
2 3
3 4
4 5


Output

2

Note

In the first sample the pairs of vertexes at distance 2 from each other are (1, 3), (1, 5), (3, 5) and (2, 4).

### Response

```cpp
#include <bits/stdc++.h>
inline int getint() {
  int x = 0, p = 1;
  char c;
  c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int maxn = 1e5 + 5;
vector<int> G[maxn];
bool is_centroid[maxn];
int n, m, res, ison[maxn], ds[505], tds[505];
int cnt_son(int x, int p) {
  int ans = 1;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    ans += cnt_son(to, x);
  }
  return ison[x] = ans;
}
inline int cnt_pairs(vector<int> &ds) {
  int j = ds.size(), ans = 0;
  sort(ds.begin(), ds.end());
  for (int(i) = 0; (i) < (ds.size()); (i)++) {
    while (j > 0 && ds[i] + ds[j - 1] > m) j--;
    ans += j - ((j > i) ? 1 : 0);
  }
  return ans / 2;
}
void enumerate_paths(int x, int p, int len) {
  tds[len]++;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    if (len + 1 <= m) enumerate_paths(to, x, len + 1);
  }
}
pair<int, int> get_centroid(int x, int p, int tot) {
  pair<int, int> ans = make_pair(1000000000, 0);
  int c = 0, ileft = 1;
  for (int(i) = 0; (i) < (G[x].size()); (i)++) {
    int to = G[x][i];
    if (to == p || is_centroid[to]) continue;
    ans = min(ans, get_centroid(to, x, tot));
    c = max(c, ison[to]);
    ileft += ison[to];
  }
  c = max(c, tot - ileft);
  ans = min(ans, make_pair(c, x));
  return ans;
}
void work(int x) {
  cnt_son(x, -1);
  int s = get_centroid(x, -1, ison[x]).second;
  is_centroid[s] = true;
  for (int(i) = 0; (i) < (G[s].size()); (i)++) {
    int to = G[s][i];
    if (is_centroid[to]) continue;
    work(to);
  }
  memset(ds, 0, sizeof(ds));
  ds[0]++;
  for (int(i) = 0; (i) < (G[s].size()); (i)++) {
    int to = G[s][i];
    if (is_centroid[to]) continue;
    memset(tds, 0, sizeof(tds));
    enumerate_paths(to, s, 1);
    for (int(j) = 0; (j) < (m + 1); (j)++) res += tds[j] * ds[m - j];
    for (int(j) = 0; (j) < (m + 1); (j)++) ds[j] += tds[j];
  }
  is_centroid[s] = false;
}
int main() {
  n = getint();
  m = getint();
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    int x, y;
    x = getint();
    y = getint();
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  work(0);
  printf("%d\n", res);
  return 0;
}

```