#C8100. Strongly Connected Street Network

    ID: 52046 Type: Default 1000ms 256MiB

Strongly Connected Street Network

Strongly Connected Street Network

You are given a directed graph representing a city's street network, where nodes represent intersections and edges represent one-way streets between intersections. The task is to determine whether the network is strongly connected (i.e. every intersection can reach every other intersection through one or more streets). If the network is not strongly connected, compute the minimum number of new one-way streets that must be added to make the network strongly connected.

Note: A network is strongly connected if and only if, starting from any intersection, you can reach every other intersection. In this problem, you can assume that the intersections are numbered from 1 to n.

inputFormat

The first line contains two integers n and m, where n is the number of intersections and m is the number of one-way streets. Each of the next m lines contains two integers u and v, representing a street from intersection u to intersection v.

Input is read from stdin.

outputFormat

Output a single integer to stdout. If the network is already strongly connected, print 0. Otherwise, print the minimum number of additional streets required to make the network strongly connected.

## sample
4 4
1 2
2 3
3 4
4 1
0