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

int N, M;
int[][] adj;
int[] color;
UnionFind uf;

bool is_bipartite(int n, int c) {
    if (color[n] >= 0 && color[n] == c) return true;
    if (color[n] >= 0 && color[n] != c) return false;
    color[n] = c;
    int nc = 1 ^ c;

    foreach (m; adj[n]) {
        if (color[m] >= 0 && color[m] != nc) return false;
        else if (color[m] >= 0) continue;
        else if (!is_bipartite(m, nc)) return false;
    }
    return true;
}

void main() {
    auto s = readln.split.map!(to!int);
    N = s[0];
    M = s[1];
    uf = new UnionFind(N);
    color = new int[](N);
    fill(color, -1);
    adj = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        adj[s[0]-1] ~= s[1] - 1;
        adj[s[1]-1] ~= s[0] - 1;
        uf.unite(s[0]-1, s[1]-1);
    }

    long ans = 0;
    long isolated = 0;
    int[] roots;
    bool[] is_b;
    foreach (i; 0..N) {
        if (uf.table[i] == -1) {
            isolated += 1;
            ans += 2 * N - (2 * isolated - 1);
        }
        else if (uf.table[i] < 0) {
            roots ~= i;
            is_b ~= is_bipartite(i, 0);
        }
    }

    long sumb = is_b.sum;
    foreach (i; 0..roots.length) {
        sumb -= is_b[i];
        long sumnotb = roots.length.to!long - i.to!long - 1 - sumb;
        //if (is_b[i]) {
        ans += is_b[i] ? 2 : 1;
        ans += 2 * sumb;
        ans += sumnotb;
        //}
        //else {
        //    ans += 1;
        //    ans += roots.length.to!long - i.to!long - 1;
        //}
    }

    ans.writeln;

}

class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] < table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}
