eolymp
bolt
Try our new interface for solving problems
Problems

Cow at Large

Cow at Large

Time limit 1 second
Memory limit 128 MiB

Cornered at last, Bessie has gone to ground in a remote farm. The farm consists of n barns and n1 bidirectional tunnels between barns, so that there is a unique path between every pair of barns. Every barn which has only one tunnel is an exit. When morning comes, Bessie will surface at some barn and attempt to reach an exit.

But the moment Bessie surfaces, the law will be able to pinpoint her location. Some farmers will then start at various exit barns, and attempt to catch Bessie. The farmers move at the same speed as Bessie (so in each time step, each farmer can move from one barn to an adjacent barn). The farmers know where Bessie is at all times, and Bessie knows where the farmers are at all times. The farmers catch Bessie if at any instant a farmer is in the same barn as Bessie, or crossing the same tunnel as Bessie. Conversely, Bessie escapes if she reaches an exit barn before any farms catch her.

Bessie is unsure about her chances of success, which depends on the number of farmers that the law is able to deploy. Given that Bessie surfaces at barn k, help Bessie determine the minimum number of farmers who would be needed to catch Bessie, assuming that the farmers distribute themselves optimally among the exit barns.

Input data

The first line contains n (2n10^5) and k. Each of the following n1 lines specify two integers, each in the range 1..n, describing a tunnel between two barns.

Output data

Output the minimum number of farmers needed to ensure catching Bessie.

Examples

Input example #1
7 1
1 2
1 3
3 4
3 5
4 6
5 7
Output example #1
3
Source 2018 USACO January, Gold