#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, m; cin>>n>>m;
    vector<vector<int>> g(n);
    for(int i=0; i<m; ++i) {
        int a, b; cin>>a>>b;
        --a, --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> color(n);
    function<bool(int, int)> is_bipartite=[&](int v, int c)->bool{
        bool res=true;
        color[v]=c;
        for(int u: g[v]) {
            if (color[u]==c) return false;
            if (color[u]) continue;
            res=res&&is_bipartite(u, -c);
        }
        return res;
    };

    if (is_bipartite(0, 1)) {
        long b=0, w=0;
        for(int c: color) ++(c>0?b:w);
        cout<<b*w-m<<endl;
    }
    else {
        cout<<n*(n-1L)/2-m<<endl;
    }
}