Under construction

Still being built. Things may change

Koosaga's problem

Time limit2sMemory limit1024 MB

Summary
Count the edge subsets of size at most two that make the connected graph bipartite, where no smaller removal set also works.
Level

Hard8 of 10

Topics
Graph, BFS, Combinatorics
Solved
No attempts yet

Problem

Jaehyun solved a problem about the maximum cut of a graph at the Petrozavodsk Winter 2019 camp, so he decided to give you another problem of the same nature.

You are given a simple connected graph G=(V,E)G = (V, E) with NN vertices and MM edges. Find the number of edge subsets S⊆ES \subseteq E that satisfy the following:

  • Removing the edges in SS makes the graph bipartite.
  • ∣S∣≤2|S| \le 2.
  • No other subset T⊆ET \subseteq E with ∣T∣<∣S∣|T| < |S| satisfies the first two conditions.

Note that SS can be empty.

Input

The first line contains two integers NN and MM (3≤N≤2500003 \le N \le 250000, N−1≤M≤250000N-1 \le M \le 250000).

Each of the next MM lines contains two space-separated integers uiu_i and viv_i (1≤ui,vi≤N1 \le u_i, v_i \le N), describing an edge between vertex uiu_i and vertex viv_i.

The graph has no loops or multiple edges, and it is connected.

Output

Print the number of edge subsets that satisfy the conditions above.

Examples4

  1. Example 1

    Input
    3 2
    1 2
    2 3
    
    Expected output
    1
    
  2. Example 2

    Input
    4 6
    1 2
    1 3
    1 4
    2 3
    2 4
    3 4
    
    Expected output
    3
    
  3. Example 3

    Input
    5 9
    1 2
    1 3
    1 4
    2 3
    2 4
    2 5
    3 4
    3 5
    4 5
    
    Expected output
    0
    
  4. Example 4

    Input
    12 16
    1 2
    2 3
    3 4
    4 1
    5 6
    6 7
    7 8
    8 9
    9 10
    10 11
    11 12
    12 5
    1 5
    2 7
    3 9
    4 11
    
    Expected output
    2