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: Runtime Error)

#include <cstdio>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
typedef long long LL;
const int N = 5005;
const int K=31;  
const int M=10921000; 
const int INF = 0x3f3f3f3f; 
const LL MOD = 998244353;
int n,m;
int a,b;
struct nd
{
    int v,nxt;
}edge[N<<1];
int head[N],cnt;
int ans;
int vis[N];
void ini()
{
    memset(head,-1,sizeof head);
    cnt=0;
}
void add_edge(int a,int b)
{
    edge[cnt].v = b;
    edge[cnt].nxt = head[a];
    head[a] = cnt++;
}
bool check(int a,int b)
{
    for (int i=head[a];~i;i=edge[i].nxt)
        if (edge[i].v == b)
            return false;
    return true;
}
void dfs(int x,int dep,int s)
{
    // cout<<" .. "<<x<<" "<<s<<endl;
    if (dep>3)
        return;
    else if (dep==3)
    {
        vis[x]=1;
        if (check(x,s))
        {
            add_edge(x,s);
            add_edge(s,x);
            ans++;
            // cout<<"bug "<<x<<" "<<s<<endl;
        }
        return;
    }
    for (int i=head[x];~i;i=edge[i].nxt)
    {
        int e = edge[i].v;
        if (vis[e]==0)
            dfs(e,dep+1,s);
    }
}
int main ()
{
    while (~scanf("%d%d",&n,&m))
    {
        ini();
        for (int i=0;i<m;i++)
        {
            scanf("%d%d",&a,&b);
            add_edge(a,b);
            add_edge(b,a);
        }
        ans=0;
        for (int k=0;k<2;k++)
            for (int i=1;i<=n;i++)
            {
                memset(vis,0,sizeof vis);
                vis[i]=1;
                dfs(i,0,i);
            }
        printf("%d\n", ans);
    }
    return 0;
}

/*

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

*/