## COCI '23 Contest 1 #5 Mostovi

View as PDF

Points: 30 (partial)
Time limit: 3.0s
Memory limit: 512M

Problem types

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!

The bridges of Zagreb form a graph with nodes and edges where the edges represent the bridges and the nodes represent the riverine islands. The graph is connected, in other words, it's possible to get from any node to any other by traveling across the edges. Now Euler asked, how many edges are there such that after their removal, the graph becomes disconnected?

Again, Euler didn't know that this problem is also famous today (those damn Codeforces blogs). So the author of this problem decided to give you an even harder one, how many edges are there such that after the removal of the nodes which it connects, the remaining nodes become disconnected?

#### Input Specification

The first line contains integers and , the number of nodes and edges respectively.

Each of the next lines contains integers and , meaning nodes and are connected with an edge.

There are no loops or multiple edges.

#### Output Specification

In a single line, output the number of edges with the given property.

1 13 ,
2 17 ,
3 25
4 12

#### Sample Input 1

4 5
1 2
2 3
3 4
4 1
1 3

#### Sample Output 1

1

#### Explanation for Sample 1

By removing edge and corresponding nodes and , the remaining graph has two connected components, node and node . In other words, it is not connected. It is easy to check that this is the only edge with this property.

#### Sample Input 2

6 7
1 2
2 4
2 6
3 5
6 1
4 3
2 5

#### Sample Output 2

4

#### Explanation for Sample 2

The edges with the required property are and .