The sites of a cable network are interconnected by cables such that a cable connects a single pair of distinct sites, and a pair of sites can be connected by several cables. We say that the network is connected if any two sites in the network are directly or indirectly connected;
otherwise the network is disconnected. The safety grade S of the network is defined as follows.
S is 0 if the network is disconnected, or the number of sites is 0 or 1.
If the number of sites is greater than 1 then S is the minimum number of cables that disconnect the network when removed, i.e. removing any S-1 cables keeps the net connected, while the removal of some S cables disconnects the net.

For example, consider the net in figure 1, where the sites correspond to the shadowed circles and the cables are indicated by lines. The network stays connected when removing any single cable, whereas the removal of cables (0,2), and (1,3) disconnects the net. Another variant for disconnecting the net is by removing the cables (2,4) and (2,4). The safety grade is S=2.
Write a program that reads several data sets from a text file and computes the safety grade of the cable networks the data sets encode.