#include <bits/stdc++.h>
using namespace std;
template <class T>
T sq(T x) {
  return x * x;
}
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const long long maxint = 2147483647;
const long long minint = -2147483648;
long long gcd(long long a, long long b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = res * x;
    x = x * x;
    p >>= 1;
  }
  return res;
}
long long bigmod(long long a, long long p, long long mod) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    p >>= 1;
  }
  return res;
}
vector<int> adj[50010], adj2[50010];
long long memo[50010][510];
long long dp(int node, int k) {
  if (k == 0) return 1;
  if (memo[node][k] != -1) return memo[node][k];
  long long res = 0;
  int i;
  for (i = 0; i < adj[node].size(); i++) {
    int t = adj[node][i];
    res += dp(t, k - 1);
  }
  return memo[node][k] = res;
}
int vis[50010];
void dfs(int s) {
  vis[s] = 1;
  int i;
  for (i = 0; i < adj2[s].size(); i++) {
    int t = adj2[s][i];
    if (vis[t] == 1) continue;
    adj[s].push_back(t);
    dfs(t);
  }
}
int main() {
  memset(memo, -1, sizeof memo);
  int n, k;
  scanf("%d %d", &n, &k);
  int i;
  for (i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj2[u].push_back(v);
    adj2[v].push_back(u);
  }
  dfs(1);
  long long res = 0;
  int j, x;
  for (i = 1; i <= n; i++) {
    res += dp(i, k);
    long long temp = 0;
    for (j = 0; j < adj[i].size(); j++) {
      int t = adj[i][j];
      for (x = 1; x < k; x++) {
        temp += dp(t, x - 1) * (dp(i, k - x) - dp(t, k - x - 1));
      }
    }
    res += temp / 2;
  }
  printf("%I64d\n", res);
  return 0;
}

### Prompt

Please formulate 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>
using namespace std;
template <class T>
T sq(T x) {
  return x * x;
}
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const long long maxint = 2147483647;
const long long minint = -2147483648;
long long gcd(long long a, long long b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = res * x;
    x = x * x;
    p >>= 1;
  }
  return res;
}
long long bigmod(long long a, long long p, long long mod) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    p >>= 1;
  }
  return res;
}
vector<int> adj[50010], adj2[50010];
long long memo[50010][510];
long long dp(int node, int k) {
  if (k == 0) return 1;
  if (memo[node][k] != -1) return memo[node][k];
  long long res = 0;
  int i;
  for (i = 0; i < adj[node].size(); i++) {
    int t = adj[node][i];
    res += dp(t, k - 1);
  }
  return memo[node][k] = res;
}
int vis[50010];
void dfs(int s) {
  vis[s] = 1;
  int i;
  for (i = 0; i < adj2[s].size(); i++) {
    int t = adj2[s][i];
    if (vis[t] == 1) continue;
    adj[s].push_back(t);
    dfs(t);
  }
}
int main() {
  memset(memo, -1, sizeof memo);
  int n, k;
  scanf("%d %d", &n, &k);
  int i;
  for (i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj2[u].push_back(v);
    adj2[v].push_back(u);
  }
  dfs(1);
  long long res = 0;
  int j, x;
  for (i = 1; i <= n; i++) {
    res += dp(i, k);
    long long temp = 0;
    for (j = 0; j < adj[i].size(); j++) {
      int t = adj[i][j];
      for (x = 1; x < k; x++) {
        temp += dp(t, x - 1) * (dp(i, k - x) - dp(t, k - x - 1));
      }
    }
    res += temp / 2;
  }
  printf("%I64d\n", res);
  return 0;
}

```