Empire
The Empire consists of planets. Lets label these planets with numbers from to . The planet with the number is a capital of Empire, where the Emperor residence is located and the troops are prepared. On different planets of the empire the uprisings are often, which must be suppressed by force and immediately.
In order for troops to move quickly, the one-way teleports are installed on some planets. There are teleports in total. Using the -th teleport you can get instantly from planet to planet (but not vice versa). Thus, it is possible to crush the rebellion in time on some planet , if there is a sequence of planets such that , and for each there is a teleport from planet with number to the planet with number . After crushing the uprising, the troops remain on the planet to maintain the order, so we do not need to worry about their return to the capital.
Check is there an opportunity using the existing system of teleports to crush the rebellion on any planet of the Empire. If so, print . Otherwise find the minimum number of teleports that must be built more so that the rebellion on any planet can be suppressed instantly. Each new teleport can be constructed between any two planets.
Input
The first line contains two integers and . The -th of the next lines contains the pair of numbers for all . No one planet has a teleport to itself. No one planet has two teleports to the same planet.
Output
Print the minimum number of teleports, ensuring that the revolt on any planet can be immediately suppressed.