#P5908. Lazy Cat's Penguin Visits
Lazy Cat's Penguin Visits
Lazy Cat's Penguin Visits
In the kingdom, there are \(n\) residential areas connected by \(n-1\) roads, forming a tree. Every road has a length of \(1\). Except for area \(1\), each area houses a little penguin. One day, a cat starts from area \(1\) with the intention to visit some penguins. However, being very lazy, the cat only wants to visit those areas that are within a distance of \(d\) from area \(1\).
Your task is to determine the number of penguins the cat can visit.
inputFormat
The first line contains two integers (n) and (d) separated by a space, where (n) is the number of residential areas and (d) is the maximum travel distance the cat is willing to cover. Each of the following (n-1) lines contains two integers (u) and (v), representing a bidirectional road connecting areas (u) and (v).
outputFormat
Output a single integer representing the number of penguins (i.e. residential areas excluding area (1)) that the cat can visit.
sample
3 1
1 2
1 3
2
</p>