atcoder#CODEFESTIVAL2017QUALBC. 3 Steps

3 Steps

Score : 500500 points

Problem Statement

Rng has a connected undirected graph with NN vertices. Currently, there are MM edges in the graph, and the ii-th edge connects Vertices AiA_i and BiB_i.

Rng will add new edges to the graph by repeating the following operation:

  • Operation: Choose uu and vv (uv)(u \neq v) such that Vertex vv can be reached by traversing exactly three edges from Vertex uu, and add an edge connecting Vertices uu and vv. It is not allowed to add an edge if there is already an edge connecting Vertices uu and vv.

Find the maximum possible number of edges that can be added.

Constraints

  • 2N1052 \leq N \leq 10^5
  • 1M1051 \leq M \leq 10^5
  • 1Ai,BiN1 \leq A_i,B_i \leq N
  • The graph has no self-loops or multiple edges.
  • The graph is connected.

Input

Input is given from Standard Input in the following format:

NN MM

A1A_1 B1B_1

A2A_2 B2B_2

::

AMA_M BMB_M

Output

Find the maximum possible number of edges that can be added.

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

If we add edges as shown below, four edges can be added, and no more.

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

Five edges can be added, for example, as follows:

  • Add an edge connecting Vertex 55 and Vertex 33.
  • Add an edge connecting Vertex 55 and Vertex 22.
  • Add an edge connecting Vertex 44 and Vertex 11.
  • Add an edge connecting Vertex 44 and Vertex 22.
  • Add an edge connecting Vertex 44 and Vertex 33.