import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n, m;
    scan(n, m);

    auto adj = new int[][](n, 0);

    foreach (i ; 0 .. m) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    bool nibu = true;
    auto col = new int[](n);
    col[] = -1;
    col[0] = 0;

    void dfs(int u) {
        foreach (v ; adj[u]) {
            if (col[v] == -1) {
                col[v] = col[u] ^ 1;
                dfs(v);
            }
            else if (col[v] == col[u]) {
                nibu = false;
                return;
            }
        }
    }

    dfs(0);

    debug {
        writeln(col);
    }

    int x = col.count!"a == 0".to!int;
    int y = n - x;

    long ans;

    if (nibu) {
        ans = 1L * x * y - m;
    }
    else {
        ans = 1L * n * (n - 1) / 2 - m;
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}