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3 9
9 10
 10 10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 1
 3 0
 6 6
1 2
2 3
3 1
4 5
5 6
6 4
 10 0
 9 15
1 2
2 3
3 1
1 4
4 5
5 1
1 6
6 7
7 1
1 8
8 9
9 1
2 9
7 4
2 8
 4 0
 1 0

1
 0
 43
 0
 8
 0
 84
 82
 63
 166666166667000000
 21
 30
 292
 64
 36
 0
 84
 284
 1
 37
 1
 4
 59
 50
 1
 2
 120
 28
 4
 0

/* 
 * File:   main.cpp
 * Author: ostaps
 *
 * Created on October 1, 2012, 5:35 PM
 */

#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <memory.h>
#include <map>
#include <queue>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>

using namespace std;

/*
 * 
 */

/*struct tripple
{
    int x,y,z;
    tripple(int _x, int _y, int _z)
    {
        x = _x, y = _y, z = _z;
    }
    tripple(){};
};

bool f(tripple a, tripple b)
{
    if (a.x < b.x)
        return 1;
    if (a.x > b.x)
        return 0;
    if (a.y < b.y)
        return 1;
    return 0;
}

int main(void) {
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n;
        scanf("%d",&n);
        int d[50];
        memset(d,0,sizeof(d));
        vector<tripple> v;
        for (int i = 0; i < n; i++)
        {
            int x,y,z;
            scanf("%d%d%d",&x,&y,&z);
            v.push_back(tripple(x,y,z));
        }
        sort(v.begin(),v.end(), f);
        for (int i = 1; i<= 48; i++)
        {
            for (int j = 0; j < n; j++)
                if (v[j].y == i)
                    d[i] = max(d[i], d[v[j].x] + v[j].z);
            d[i] = max(d[i], d[i-1]);
        }
        printf("%d\n", d[48]);
    }
    
    return 0;
}
*/

/*int a[105][10005];
int l[105][10005];
int r[105][10005];
int main(void)
{
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf("%1d",&a[i][j]);
    for (int i = 0; i < n; i++)
    {
        if (a[i][0] == 1)
            l[i][0] = 0; else
            {
                int j = m-1;
                while (j && (a[i][j] == 0))
                    j--;
                if (!j)
                {
                    printf("-1\n");
                    return 0;
                }
               
                l[i][0] = m - j;
            }
        for (int j = 1; j < m; j++)
            if (a[i][j] == 1)
                l[i][j] = 0; else
                    l[i][j] = l[i][j-1] + 1;
    }
    
    for (int i = 0; i < n; i++)
    {
        if (a[i][m-1] == 1)
            r[i][m-1] = 0; else
            {
                int j = 0;
                while ((j != (m-1)) && (a[i][j] == 0))
                    j++;
                if (j == (m-1))
                {
                    printf("-1\n");
                    return 0;
                }
                r[i][m-1] = i + 1;
            }
        for (int j = m-2; j >=0; j--)
            if (a[i][j] == 1)
                r[i][j] = 0; else
                    r[i][j] = r[i][j+1] + 1;
    }
    int res = 100000000;
    for (int i = 0; i < m; i++)
    {
        int tmp = 0;
        for (int j = 0;  j < n; j++)
            tmp += min(l[j][i], r[j][i]);
        res = min(res,tmp);
    }
    printf("%d\n",res);
    return 0;
}
*/
int n,m;
vector<vector<int> > g;
bool mark[1000005];
__int64 cnt = 0;
int fnd = 0;
__int64 ans = 0;
void dfs(int v)
{
    mark[v] = 1;
    for (int i = 0; i < g[v].size(); i++)
    {
        fnd = 1;
        int u = g[v][i];
        if (!mark[u])
            dfs(u);
    }
}
int main(void)
{
    scanf("%d%d",&n,&m);
    g.resize(n);
    for (int i = 0; i < m; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x--,y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    __int64 tmp;
    tmp = (__int64) n * (__int64) (n-1) / 2;
    __int64 tmp2 = 0;
    for (int i = 0; i < n; i++)
        if (!mark[i])
        {
            fnd = 0;
            dfs(i);
            if (fnd)
            {
                cnt++;
            }
            else
                    mark[i] = 0;
        }
    int n1 = 0;
    for (int i = 0; i < n; i++)
        if (mark[i])
            n1++;
    ans = m - n1 + cnt;
    tmp -= (__int64)ans;
    tmp -= (__int64) m * 3;
    tmp += (__int64) ans *3;
    tmp = (tmp < 0) ? -tmp : tmp;
   // cout << tmp << ans << m * 3 << endl;
    //tmp = (__int64) m * 3 - ans - tmp;
    printf("%I64d\n",tmp + (__int64) ans);;
    return 0;
}
