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: Accepted)

#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, M;
vector<vector<ll>> edges;
vector<ll> check;

bool isBiparateGraph() {
	check.resize(N, -1);
	stack<pll> st;
	st.push(pll(0, 0));   //頂点、色
	while (!st.empty()) {
		pll cur = st.top();
		st.pop();
		if (check[cur.first] == -1) {
			check[cur.first] = cur.second;
			for (ll ch : edges[cur.first]) {
				st.push(pll(ch, 1 - cur.second));
			}
		}
		else {
			if (check[cur.first] != cur.second) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	edges.resize(N);
	for (ll m = 0; m < M; m++) {
		ll a, b;
		cin >> a >> b;
		edges[--a].push_back(--b);
		edges[b].push_back(a);
	}
	bool isb = isBiparateGraph();
	if (isb) {
		ll zero = 0, one = 0;
		for (ll n = 0; n < N; n++) {
			if (check[n] == 0)zero++;
			else one++;
		}
		cout << zero * one - M << endl;
		return 0;
	}
	else {
		cout << N * (N - 1) / 2 - M << endl;
		return 0;
	}
}