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
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;


import java.util.ArrayList;
import java.util.PriorityQueue;



public final class CF_407_Journey {

	static void log(int[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}


	static void log(long[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}
	static void log(Object[] X){
		int L=X.length;
		for (int i=0;i<L;i++){
			logWln(X[i]+" ");
		}
		log("");
	}


	static void log(Object o){
		logWln(o+"\n");
	}

	static void logWln(Object o){
		System.err.print(o);
		//	outputWln(o);

	}
	static void info(Object o){
		System.out.println(o);
		//output(o);
	}

	static void output(Object o){

		outputWln(""+o+"\n");

	}

	static void outputWln(Object o){
		// System.out.print(o);

		try {
			out.write(""+ o);
		} catch (Exception e) {

		}
	}


	static ArrayList<Integer>[] friends;
	static int N,M;
	static long loops;
	static int[] X,Y;
	static int MM;


	static int[] anc,rank,max,list;


	static void initSet(int x){
		anc[x]=x;
		rank[x]=0;
		max[x]=x;
	}

	static void union(int x,int y){
		//log("unioning x:"+x+" y:"+y);
		int xr=find(x);
		int yr=find(y);
		if (xr!=yr){
			if (rank[xr]<rank[yr]){
				anc[xr]=yr;
				max[yr]=Math.max(max[xr],max[yr]);
				//	max[xr]=max[yr];
			} else if (rank[xr]>rank[yr]) {
				anc[yr]=xr;
				max[xr]=Math.max(max[xr],max[yr]);
				//	max[xr]=max[yr];

			} else {
				anc[yr]=xr;
				rank[xr]++;
				max[xr]=Math.max(max[xr],max[yr]);
				//max[xr]=max[yr];
			}
		}
	}

	static int find(int x){
		if (anc[x]!=x){
			anc[x]=find(anc[x]);
		}
		return anc[x]; 
	}
	
	static int[] nf;

	static void readGraph() throws Exception {

		anc=new int[N];
		rank=new int[N];
		max=new int[N];
		nf=new int[N];
		for (int x=0;x<N;x++)
			initSet(x);
		//log("read graph");


		int st=0;
		for (int i=0;i<M;i++){
			int x=reader.readInt()-1;
			int y=reader.readInt()-1;
			if (x==y)
				loops++;
			else {
				nf[x]++;
				nf[y]++;
				union(x,y);
			}
		}	
	}

	static boolean checkConnected(){
		int[] stack=new int[N];
		boolean[] visited=new boolean[N];
		int p=0;
		stack[p++]=0;
		visited[0]=true;
		int cnt=1;
		while (p>0){
			int u=stack[p-1];
			p--;
			for (int v:friends[u]){
				if (!visited[v]){
					stack[p++]=v;
					visited[p]=true;
					cnt++;
				}
			}
		}
		return cnt==N;
	}


	// Global vars
	static BufferedWriter out;
	static InputReader reader;




	static void process() throws Exception {



		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader=new InputReader(System.in);

		N=reader.readInt();
		M=reader.readInt();
		readGraph();
		if (M-loops<N-1 ){
			output("0");
		}
		else {

			int a=find(0);
			boolean connected=true;
			for (int i=1;i<N && connected;i++){
				if (find(i)!=a)
					connected=false;
			}

			if (connected){

				// several options:
				// a) make full transversal A/R, but avoid 2 loops node//  loops*(loops-1)/2 
				// b) make transversal A/R, avoid 1 loop + one edge //  (M-loops)*loops
				// c) make transversal A/R, avoir 2 edeges. must be the first and last...Which is, they should be connected to same node

				long sc=0;
				for (int i=0;i<N;i++){
					long x=nf[i];
					sc+=(x*(x-1))/2;
				}
				long sa=(loops*(loops-1))/2;
				long sb=(M-loops)*loops;
				//log(sa+" "+sb+" "+sc);
				output(sa+sb+sc);
			} else {
				output("0");
			}
		}

		try {
			out.close();
		}
		catch (Exception e){}


	}


	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}


		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}




		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}


}