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.stdio;

int[][] adj;
bool[] used;

int dfs(int n) {
    used[n] = true;
    int ret = 1;
    foreach (m; adj[n]) {
        if (!used[m]) {
            ret += dfs(m);
        }
    }
    return ret;
}

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto M = s[1];

    adj = new int[][](N);
    used = new bool[](N);

    foreach (_; 0..M) {
        auto t = readln.split.map!(to!int);
        adj[t[0]-1] ~= t[1]-1;
        adj[t[1]-1] ~= t[0]-1;
    }

    long ans = 0;
    foreach (i; 0..N) {
        if (!used[i] && adj[i].length > 0) {
            int ret = dfs(i.to!int);
            //ret.writeln;
            if (ret == 2)
                ans += 2;
            else
                ans += 1;
        }
    }


    long iso = 0;
    foreach (i; 0..N) {
        if (adj[i].length == 0) iso += 1;
    }
    //ans.writeln;
    //iso.writeln;

    foreach (i; 0..N) {
        if (adj[i].length == 0) {
            ans += N;
        }
        else {
            ans += iso;
        }
    }

    ans.writeln;
}
