The number of path in tree that have at least length k.

Revision en2, by EonHino, 2018-11-21 19:09:25

Statement

Given an undirected tree, count how many paths that have at least length of k.

Input

The first line is n (n <= 10 ^ 5) and k (k <= n) — the number of vertices and k as mentioned above.

Next n — 1 line represents an edge.

5 2

1 2

2 3

2 4

4 5

Output

6

Explain

All paths that have at least length of k:

(1,3): 1-2-3

(1,4): 1-2-4

(1,5): 1-2-4-5

(2,5): 2-4-5

(3,4): 3-2-4

(3,5): 3-2-4-5

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English EonHino 2018-11-21 19:09:25 111
en1 English EonHino 2018-11-21 14:16:38 511 Initial revision (published)