题目描述
The statement of this problem is short and simple. There is a tree with vertices labelled from 1 to N. You are supposed to count the total number of such pairs in a tree that satisfy the given properties :
A pair (A,B) should be counted when
A is the ancestor of node B.
The product of values of the node A and B is not greater than a fixed value K.
The value of the node is same as its label.
Input :
The first line of input contains two integers N and K. This is followed by N-1 lines, each containing two
integers S and D where node S is the parent of node D.
Output:
Print the total number of pairs in the tree.
Constraints:
1 ≤ N ≤10^5
1 ≤ K ≤10^10
1 ≤ S,D ≤N
SAMPLE INPUT
4 3
1 2
1 3
1 4
SAMPLE OUTPUT
2
Explanation
The required pairs are (1,2) and (1,3).
输入格式
见题面
输出格式
见题面