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.
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 "*a*<sub class="lower-index">*i*</sub> *b*<sub class="lower-index">*i*</sub>" (without the quotes) (1 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub> ≤ *n*, *a*<sub class="lower-index">*i*</sub> ≠ *b*<sub class="lower-index">*i*</sub>), where *a*<sub class="lower-index">*i*</sub> and *b*<sub class="lower-index">*i*</sub> are the vertices connected by the *i*-th edge. All given edges are different.
5 2
1 2
2 3
3 4
2 5
4
5 3
1 2
2 3
3 4
4 5
2
10 1
2 1
3 1
4 3
5 4
6 5
7 1
8 6
9 2
10 6
9
10 2
2 1
3 1
4 3
5 4
6 5
7 1
8 6
9 2
10 6
10
10 3
2 1
3 1
4 3
5 4
6 5
7 1
8 6
9 2
10 6
8
50 3
2 1
3 2
4 3
5 4
6 5
7 6
8 7
9 8
10 9
11 10
12 11
13 12
14 13
15 14
16 15
17 16
18 17
19 18
20 19
21 20
22 21
23 22
24 23
25 24
26 25
27 26
28 27
29 28
30 29
31 30
32 31
33 32
34 33
35 34
36 35
37 36
38 37
39 38
40 39
41 40
42 41
43 42
44 43
45 44
46 45
47 46
48 47
49 48
50 49
47
50 4
2 1
3 1
4 2
5 2
6 3
7 3
8 4
9 4
10 5
11 5
12 6
13 6
14 7
15 7
16 8
17 8
18 9
19 9
20 10
21 10
22 11
23 11
24 12
25 12
26 13
27 13
28 14
29 14
30 15
31 15
32 16
33 16
34 17
35 17
36 18
37 18
38 19
39 19
40 20
41 20
42 21
43 21
44 22
45 22
46 23
47 23
48 24
49 24
50 25
124
50 5
2 1
3 1
4 2
5 2
6 4
7 4
8 6
9 6
10 8
11 8
12 10
13 10
14 12
15 12
16 14
17 14
18 16
19 16
20 18
21 18
22 20
23 20
24 22
25 22
26 24
27 24
28 26
29 26
30 28
31 28
32 30
33 30
34 32
35 32
36 34
37 34
38 36
39 36
40 38
41 38
42 40
43 40
44 42
45 42
46 44
47 44
48 46
49 46
50 48
84
10 20
2 1
3 2
4 1
5 3
6 4
7 1
8 2
9 7
10 2
0
#include<cstdio>
#include<vector>
#include<algorithm>
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
inline void chkmax(int &x, int y){x<y?(x=y):0;}
const int N=50005;
vector<pair<int, int> > G[N];
int size[N], Max[N], dis[N], vis[N];
int sum, cnt, rt, n, K; long long ans;

inline int read()
{
 	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}

#define v i.first
#define w i.second

void GetRoot(int u, int fa)
{
	size[u]=1; Max[u]=1;
	for (auto i: G[u]) if (v^fa && !vis[v])
		GetRoot(v, u), chkmax(Max[u], size[v]), size[u]+=size[v];	
	chkmax(Max[u], sum-size[u]);
	if (Max[u]<Max[rt]) rt=u;
}

int LeftBound(int l, int x)
{
	int r=cnt;
	while (l<r) 
	{
		int mid=l+r>>1;
		if (dis[mid]<x) l=mid+1; else r=mid;
	}
	return l;
}

int RightBound(int l, int x)
{
	int r=cnt;
	while (l<r)
	{
		int mid=l+r+1>>1;
		if (dis[mid]<=x) l=mid; else r=mid-1;
	}
	return l;
}

void GetDis(int u, int fa, int Dis)
{
	for (auto i: G[u]) if (v^fa && !vis[v])
		dis[++cnt]=Dis+w, GetDis(v, u, dis[cnt]);
}

int GetAns(int u, int Dis)
{
	dis[cnt=1]=Dis; GetDis(u, 0, Dis);
	sort(dis+1, dis+cnt+1);
	int l=1, ans=0;
	while (l<cnt && dis[l]+dis[cnt]<K) l++;
	while (l<cnt && dis[l]<<1<=K) 
	{
		int DisL=LeftBound(l+1, K-dis[l]);
		int DisR=RightBound(l+1, K-dis[l]);
		//printf("%d %d %d %d %d %d\n", u, Dis, l, DisL, DisR, ans);
		if (DisR>=DisL) ans+=DisR-DisL+1;
		l++;
	}
	return ans;
}

void dfs(int u)
{
	vis[u]=1; ans+=GetAns(u, 0); //printf("%d %d\n", u, ans);
	for (auto i: G[u]) if (!vis[v])
	{
		ans-=GetAns(v, w); 
		sum=size[v]; rt=0; GetRoot(v, u); dfs(rt);
	} //printf("%d %d\n", u, ans);
}

#undef v
#undef w

int main()
{
	n=read(); K=read();
	rep(i, 1, n-1)
	{
		int u=read(), v=read();
		G[u].push_back(make_pair(v, 1));
		G[v].push_back(make_pair(u, 1));
	}
	sum=Max[rt=0]=n; GetRoot(1, 0); dfs(rt);
	//rep(i, 1, n) printf("%d ", Max[i]);puts("");
	//rep(i, 1, n) printf("%d ", size[i]);puts("");
	printf("%lld\n", ans);
	return 0;
}
