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
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter writer = new PrintWriter(System.out);
		String[] s=br.readLine().split(" ");
		int n=Integer.parseInt(s[0]);
		int m=Integer.parseInt(s[1]);
		int[] deg=new int[n+1];
		for(int i=1;i<=n;i++){deg[i]=0;}
		int loop=0;
		UnionFind uf=new UnionFind(n);
		for(int i=0;i<m;i++){
			String[] t=br.readLine().split(" ");
			int u=Integer.parseInt(t[0]);
			int v=Integer.parseInt(t[1]);
			if(u==v){loop++;}
			else{
				uf.union(u,v);
				deg[u]++;
				deg[v]++;
				
			}
		}
		int r=uf.findRoot(1);
		for(int i=2;i<=n;i++){
			if(uf.findRoot(i)!=r){
				writer.println(0);
				return;
			}
		}
		long res=0;
		for(int i=1;i<=n;i++){
			res+=((long)deg[i]*(long)(deg[i]-1));
		}
		res/=2;
		res+=(long)loop*(long)(m-loop);
		res+=((long)loop*(long)(loop-1))/2;
		writer.println(res);
		writer.close();
		/*Map memo=new HashMap();
		for(int i=1;i<=n;i++){
			memo.put(i,new ArrayList());
		}
		int loop=0;
		int[] deg=new int[n+1];
		for(int i=1;i<=n;i++){deg[i]=0;}
		for(int i=0;i<m;i++){
			String[] t=br.readLine().split(" ");
			int u=Integer.parseInt(t[0]);
			int v=Integer.parseInt(t[1]);
			if(u==v){loop++;}
			else{
				ArrayList au=(ArrayList)memo.get(u);
				ArrayList av=(ArrayList)memo.get(v);
				au.add(v);
				av.add(u);
				memo.put(u,au);
				memo.put(v,av);
				deg[u]++;
				deg[v]++;
			}
		}
		Graph gr=new Graph(memo,n);
		long res=0;
		if(gr.isok()==false){
			System.out.println(0);
		}
		else{
			for(int i=1;i<=n;i++){
				res+=((long)deg[i]*(long)(deg[i]-1))/2;
			}
			res+=(long)loop*(long)(m-loop);
			res+=((long)loop*(long)(loop-1))/2;
			System.out.println(res);
		}*/
	}
}

/*class Graph{
	Map memo; //edges
	//int[] deg; //degree minus self-loops
	int n;
	
	Graph(Map mp,int N){
		n=N;
		memo=mp;
	}
	
	boolean isok(){ //check connectivity
		int[] vis=new int[n+1];
		for(int i=1;i<=n;i++){vis[i]=0;}
		Queue q=new LinkedList();
		q.add(1);
		vis[1]=1;
		while(q.peek()!=null){
			int v=(int)q.poll();
			ArrayList ar=(ArrayList)memo.get(v);
			for(int i=0;i<ar.size();i++){
				int t=(int)ar.get(i);
				if(vis[t]==0){
					q.add(t);
					vis[t]=1;
				}
			}
		}
		for(int i=1;i<=n;i++){
			if(vis[i]==0){return false;}
		}
		return true;
	}
}*/

class UnionFind{
	int[] root;
	int n;
	
	UnionFind(int N){
		n=N;
		root=new int[n+1];
		for(int i=1;i<=n;i++){root[i]=i;}
	}
	
	int findRoot(int x){
		int v=x;
		while(root[v]!=v){
			v=root[v];
		}
		return v;
	}
	
	void union(int x,int y){
		int u=findRoot(x);
		int v=findRoot(y);
		root[u]=v;
	}
}

