100 10
87 73
15 71
14 33
1 4
20 80
65 67
36 36
25 4
22 21
7 97
 4 2
3 3
3 4
 5 4
3 3
4 4
5 5
1 2
 4 4
1 2
2 3
3 1
4 4
 4 3
1 1
2 3
3 4
 1000000 1
255765 255765
 4 3
1 2
2 3
4 4
 4 2
1 1
1 2
 3 3
1 1
2 2
3 3
 5 4
1 1
2 3
2 4
2 5
 4 5
1 4
3 4
1 2
2 3
2 4
 4 4
2 3
2 4
3 4
4 4
 10 9
8 10
3 10
2 8
9 3
4 8
1 10
7 9
5 4
7 3
 10 10
1 2
2 3
3 4
4 5
5 1
6 6
7 7
8 8
9 9
10 10
 5 5
1 4
3 4
1 2
2 3
2 4
 3 3
1 2
2 2
3 3
 5 3
1 1
2 2
3 3
 6 12
1 2
1 3
2 3
1 1
2 2
3 3
4 5
5 6
4 6
4 4
5 5
6 6
 4 4
1 2
2 3
1 3
4 4
 5 4
1 2
3 3
4 4
5 5
 7 13
6 7
2 7
3 7
4 3
5 2
1 4
7 7
3 1
5 5
3 3
1 5
2 6
6 6
 2 2
1 1
2 2
 5 5
1 1
2 2
3 3
4 4
5 5
 1 1
1 1
 7 3
1 1
3 3
6 6
 3 3
1 1
2 3
3 3

0 1 0 0 0 0 0 1 0 0 8 6 12 0 8 0 0 0 0 0 57 0 0 0 0 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define em emplace_back
#define pi pair<int,int>
#define si second
#define fi first
// new include starts here.
#define endl '\n'
#define vi vector <int>
#define vii vector <pair<int,int>>
#define __s(x) cout<<#x<<"-> "; cout<<"{ ";F(x){cout<<it<<" ";}cout<<" }";cout<<endl;
#define _s(x) cout<<#x<<"-> "<<x<<endl;
#define _sp(x) cout<<#x<<"-> "<<x.fi<<" "<<x.si<<endl;
#define __sp(x) cout<<#x<<"-> "; cout<<"{ "<<endl;F(x){cout<<it.fi<<" "<<it.si<<endl;}cout<<" }";cout<<endl;
#define inf numeric_limits<int > :: max();
#define fit(it,y) for(auto it=y.begin(); it!=y.end();it++)
#define all(x) x.begin(),x.end()
// new includes end here .
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("/home/adarsh/Desktop/codes/input", "r", stdin); //freopen("/home/adarsh/Desktop/codes/output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

#define TRACE
#ifdef TRACE
#define _v(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define _v(...)
#endif

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
//int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=(p(a,b/2)); if(b%2==0)return (t*t); else return ((a)*(t*t)); } 

//---------------------------------------------------------------------------------------------------------------------------------------------
int n,m;
vi a[1000009];
vi a1[1000009];
int vis[1000009]={0};

int coun=0;

void dfsc(int s){
	vis[s]=1;
	coun+=a1[s].size();
	f(a1[s].size()){
		if(vis[a1[s][i]]!=1){
			dfsc(a1[s][i]);
		}
	}
}
int ans=0;
int vis1[1000009]={0};

void dfs(int s){
	vis1[s]=1;
	//cout<<s<<" "<<a[s].size()<<endl;
	set <int > s1;
	f(a[s].size()){
		s1.in(a[s][i]);
	}
	int z=s1.size();
	ans+=(z*(z-1))/2;
	f(a[s].size()){
		if(vis1[a[s][i]]!=1){
			dfs(a[s][i]);
		}
	}
}

signed main(){
 
	#ifndef ONLINE_JUDGE
	FILEIO
	#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----


	cin>>n>>m;
	int in=-1;
	int c1=0;

	f(m){
		int x, y;
		cin>>x>>y;
		a1[x].pb(y);
		a1[y].pb(x);
		if(x==y){
			c1++;
			continue;
		}
		a[x].pb(y);
		a[y].pb(x);
		
	}

	f(n+1){
		if(i==0){
			continue;
		}
		if(a1[i].size()!=-1){
			in=i;
		}
	}
	if(in==-1){
		cout<<0<<endl;
		return 0;
	}
	dfsc(in);
	//_v(in);
	//cout<<coun<<endl;
	if(coun/2!=m){
		cout<<0<<endl;
		//cout<<"in here"<<endl;	
		return 0;
	}
	dfs(in);
	//__s(a[1]);
	//cout<<ans<<endl;
	ans+=(m-c1)*c1+(c1*(c1-1))/2;
	cout<<ans<<endl;




	
	return 0;
}   