#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

const int maxn=100005;

int num;
int f[maxn];
bool vis[maxn];

int find(int x)
{
	return f[x]^x?find(f[x]):x;
}

int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);	
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		f[find(u)]=find(v);
	}
	for(int i=1;i<=n;i++){
		if(!vis[find(i)]){
			num++;
			vis[find(i)]=1;
		}
	}
	printf("%d\n",(num*(num-1)+num)*2);
	return 0;
}