#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

bool dual = 1;
int d[100020] = {};
vector<int> G[100010];
vector<bool> vis;

void dfs(int k, int dep) {
    vis[k] = 1;
    if (d[k] == 0) {
        if (dep % 2) d[k] = 1;
        else d[k] = 2;
    }
    for (auto &i : G[k]) {
        if (!vis[i]) {
            dfs(i, dep + 1);
        }
        else if (d[i] % 2 == dep % 2) {
            dual = 0;
            return;
        }
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    int x[m], y[m];
    vis.assign(n, 0);
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--;  y[i]--;
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }

    dfs(0, 0);
    if (dual) {
        ll p = 0, q = 0;
        for (int i = 0; i < n; i++) {
            if (d[i] == 1) p++;
            else q++;
        }
        ll ans = p * q;
        for (int i = 0; i < m; i++) {
            if (d[x[i]] != d[y[i]]) ans--;
        }
        cout << ans << endl;
    }
    else {
        cerr << 0 << endl;
        cout << n * (n - 1) / 2 - m << endl;
    }
}
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl #define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl #define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

in sum_vec(vector<int> a){
  in sum=0;
  rep(i,a.size())
    sum+=a.at(i);
  return sum;
}

vector<int> color;
bool dfs (vector<vector<int>>&G,int v,int cur){
  color.at(v)=cur;
  for(int next_v : G.at(v)){
    //cout<<"v:"<<v<<" next_v:"<<next_v<<" ";
    if(color.at(next_v)==-1){
      //cout<<"未探索"<<endl;
      if(!dfs(G,next_v,1-cur)) return false;
    }
    else{
      if(color.at(next_v)==cur) {/*cout<<"矛盾"<<endl;*/ return false;}
      if(color.at(next_v)==1-cur){/*cout<<"矛盾無し"<<endl;*/ continue;}
    }
  }
  return true;
}

int main(){
  in m;
  in n;
  cin>>n>>m;
  vector<vector<int>> G(n);
  
  rep(i,m){
    int a,b;
    cin>>a>>b;
    G.at(a-1).push_back(b-1);
    G.at(b-1).push_back(a-1);
  }
  color.assign(n,-1);
  in sum;
    
  if(dfs(G,0,0)){
    sum=sum_vec(color);
    printf("%ld \n",sum*(n-sum)-m);
  }
  else
    printf("%ld \n",(n*(n-1))/2-m);
  //color.assign(n,-1);
  //cout<<dfs(G,0,0)<<endl;
  //cout<<sum<<endl;
  //rep(i,n)
    //cout<<color.at(i);
  
}