#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

const int N=100005;

int n,m,x,y;
ll ans;
int sz[N],f[N];

int find(int k){
	if (f[k]!=k) f[k]=find(f[k]);
	return f[k];
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) f[i]=i,sz[i]=1;
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		x=find(x); y=find(y);
		if (x!=y){
			f[y]=x;
			sz[x]+=sz[y];
		}
	}
	ans=1ll*n*n;
	for (int i=1;i<=n;i++)
		if (find(i)==i){
			if (sz[i]==2) ans-=2;
			if (sz[i]==1) continue;
			if (sz[i]>2) ans-=1ll*sz[i]*sz[i]-1ll;
		}
	printf("%lld\n",ans);
	return 0;
}