/*
PAIRING PROBLEM:


tried using DSU ==> 
ex:	7 5						0			4
	0 1					  1				  5
	1 2					2   3				6	
	1 3		
	4 5
	5 6
											   indexes:	0 1 2 3  4 5 6
i have made "parents[]" such that its output will be =[-4 0 0 0 -3 4 4]

indexes are nodes and value on them are as follows:
1)-ve number=super_parent
2)-ve number ka magnitude means total components in that component
3)+ve number means position of superparent 


FOR Calculating final answer

{
		component1	|	component2	|	component3				 . . . .  . . .   component_Nth
			0		|		4		|		7
  		1			|		  5		|	  		8				.  . . .  .  .
	2		3		|			6	|	
== 	4nodes here		|	3nodes here	|		2nodes here			  . . . . . . .    Cn nodes here
}
components[3]=[4,3,2, . . . . Cn];

answer = every possible combination taking 2 elements at a time from components array;

answer = (a1+a2+a3. . . .+an)^2 - ((a1)^2+(a2)^2. . . .(an)^2)
======> this equation give every combination . . . . .
answer = answer/2, becoz combination repeat hongai 2 baar


I DID IT LIKE THIS STILL GETTING WRONG_ANS, 

code bhi check kiya pata ni kya galti hai. . . . . .logic thik thak mazboot lagra hai...

[[code aur logic mazboot lagre hai isliye DOUBT pucha]]

*/
#include<iostream>
#include<vector>
using namespace std;
const int mod_wala=1e9+7;
const int max_size=1e5+1;
vector<int> parents(max_size,-1);
int superparent(int x){
	return parents[x]<0?x:superparent(parents[x]); 
}
int main() {
	int n,m;
	long long int ans1=0,ans2=0;
	cin>>n>>m;
	while(m--){
		int x,y;
		cin>>x>>y;
		if(superparent(x)!=superparent(y)){
			if(parents[superparent(x)]<=parents[superparent(y)]){
				parents[y]=superparent(x);
				parents[superparent(x)]--;
			}else{
				swap(x,y);
				parents[y]=superparent(x);
				parents[superparent(x)]--;
			}
		}
	}
	for(int i=0;i<n;i++){
		// cout<<parents[i]<<" ";
		if(parents[i]<0){
			ans2+=parents[i];
			ans1+=parents[i]*parents[i];
			// cout<<parents[i]<<" ";
		}
	}
	cout<<(ans2*ans2-ans1)/2<<"\n";
	return 0;
}