Problem:
Score : 500 points

Problem Statement

Rng has a connected undirected graph with N vertices.
Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i.

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

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

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

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \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:

N M
A_1 B_1
A_2 B_2
:
A_M B_M

Output

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

Sample Input 1

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

Sample Output 1

4

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

Sample Input 2

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

Sample Output 2

5

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

Add an edge connecting Vertex 5 and Vertex 3.

Add an edge connecting Vertex 5 and Vertex 2.

Add an edge connecting Vertex 4 and Vertex 1.

Add an edge connecting Vertex 4 and Vertex 2.

Add an edge connecting Vertex 4 and Vertex 3.

Solution in C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

void file() {
#ifdef zjp_shadow
	freopen ("c.in", "r", stdin);
	freopen ("c.out", "w", stdout);
#endif
}

const int N = 100100, M = N << 1;
vector<int> G[N];
set<int> S[N];
int n, m;
void input() {
	n = read();
	m = read();
	For (i, 1, m) {
		int u = read(), v = read();
		G[u].push_back(v);
		S[u].insert(v);
		G[v].push_back(u);
		S[v].insert(u);
	}
}

bool vis[N];
set<int> dep[N][3];
typedef set<int>::iterator it;
int ans = 0, pre[N];
#define all(x) x.begin(), x.end()
void dfs (int u) {
	vis[u] = true;
	for (it i = dep[u][2].begin(); i != dep[u][2].end(); ++i) {
		int from = (*i);
		if (u != from && from && S[u].find(from) == S[u].end()) {
			++ ans;
			G[u].push_back(from);
			G[from].push_back(u);
			S[u].insert(from);
			S[from].insert(u);
		}
	}

	for (int i = 0; i < (G[u].size() ) ; ++i) {
		int v = G[u][i];
		if (vis[v]) continue ;
		pre[v] = u;
		dep[u][0].insert(v);
		dep[v][0].insert(u);
		dep[u][2].insert(all(dep[v][1]) );
		dep[v][2].insert(all(dep[u][1]) );
		dep[u][1].insert(all(dep[v][0]) );
		dep[v][1].insert(all(dep[u][0]) );
		dfs (v);
	}
	vis[u] = false;
}

void solve() {
	dfs (1);

}

void output() {
	printf ("%d\n", ans);
}

int main () {
	file();
	input();
	solve();
	output();
    return 0;
}