문제
Cornered at last, Bessie has gone to ground in a remote farm. The farm consists of
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
Problem credits: Dhruv Rohatgi
입력
The first line of the input contains
출력
Please output the minimum number of farmers needed to ensure catching Bessie.
예제
7 1
1 2
1 3
3 4
3 5
4 6
5 7
3