Strange Bulbs
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Christmas is coming. XiaoYang has got a big Christmas tree, and he wants to decorate it.

XiaoYang loves Shiny things. He set up a net of light bulbs on the tree. n light bulbs are connected by m wires. But the bulbs and wires are strange. Each bulb has a switch. If the switch is turned, some bulbs connecting this one will also be switched. The switch operation only flows from the left end to the right end. More precisely, a wire connects u and v so that when the switch of u is turned, the switch of v is turned also. Note that a switch will be turned only once in one step.

Now only the bulb 1 is on. How many steps does it take to turn off all the bulbs?

输入描述:

The first line contains two integers n and -- the number of bulbs and wires in the net.

Each of the next m lines contains two space-separated integers u and that mean there's a directed wire connecting the left u and the right v. It's guaranteed that the net is connected, acyclic and doesn't contain any self-loops or multiple edges.


输出描述:

One line with an integer denoting the answer.
示例1

输入

复制
6 7
1 2
1 3
2 4
3 4
2 5
5 6
4 6

输出

复制
4

说明

For the first testcase, operations are 1(2,3,4,5,6) and 2(4,5,6) and 3(4,6) and 4(6).
示例2

输入

复制
4 4
1 2
1 3
2 4
3 4

输出

复制
4

说明

For the second testcase, operations are 1(2,3,4) and 2(4) and 3(4) and 4().

备注:

Operation a (b1, b2, ..., bm) means switch bulb a in this step, and then bulb b1, b2, ..., bm are affected.
It is guaranteed that control can flow from bulb 1 to any other bulbs.