#P9907. Zagreb Bridge Problem
Zagreb Bridge Problem
Zagreb Bridge Problem
When Leonhard Euler resolved the famous Königsberg bridge problem, he had no clue he had discovered a whole new area of mathematics – graph theory!
Unfortunately, the Königsberg bridge problem is far too easy for the programmers of this era, so Euler came up with another problem – the Zagreb bridge problem!
You are given an undirected connected graph with $n$ nodes and $m$ edges (bridges). The nodes represent riverine islands while the edges represent the bridges connecting them. Euler now asks: how many edges are there such that if you remove both endpoints of the edge, the remaining $\( n-2 \)$ nodes become disconnected?
That is, for an edge connecting nodes \( u \) and \( v \), after removing both \( u \) and \( v \) from the graph, if the graph induced on the remaining nodes is disconnected, then this edge is counted.
inputFormat
The input consists of multiple lines. The first line contains two integers \( n \) and \( m \) where \( n \) is the number of nodes and \( m \) is the number of edges in the graph. Each of the following \( m \) lines contains two integers \( u \) and \( v \) indicating that there is an edge between nodes \( u \) and \( v \). The graph is guaranteed to be connected.
outputFormat
Output a single integer, the number of edges such that after removing the two nodes it connects, the remaining \( n-2 \) nodes are not connected.
sample
4 3
1 2
2 3
3 4
1