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

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


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

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

    bool nibu = true;
    int[2] cnt;
    auto c = new int[](n);
    c[] = -1;

    void dfs(int v, int col) {
        c[v] = col;
        cnt[col]++;

        foreach (u ; adj[v]) {
            if (c[u] == -1) {
                dfs(u, col ^ 1);
                continue;
            }
            if (c[u] != (col ^ 1)) {
                nibu = false;
                return;
            }
        }
    }

    dfs(0, 0);

    long ans = nibu ? 1L * cnt[0] * cnt[1] - m : 1L * n * (n - 1) / 2 - m;

    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    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);
        }
    }
}
