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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long startTime = System.currentTimeMillis();

			int n = in.nextInt();
			int m = in.nextInt();
			int[] from = new int[m];
			int[] to = new int[m];
			int[] d = new int[n];
			DisjointSetUnion dj = new DisjointSetUnion(n);
			int nt = n;
			for (int i = 0; i < m; ++i) {
				from[i] = in.nextInt() - 1;
				to[i] = in.nextInt() - 1;
				d[from[i]]++;
				d[to[i]]++;
				if (!dj.same(from[i], to[i])) {
					nt--;
					dj.merge(from[i], to[i]);
				}


			}

			if (nt > 1) {
				out.println(0);
			} else {
				long re = 0;
				for (int i = 0; i < m; ++i) {
					if (from[i] != to[i]) {
						re += d[from[i]] + d[to[i]] - 2;
					} else {
						re += d[from[i]] - 1;
					}
				}
				re /= 2;
				if (m == 2) re = 1;

				out.println(re);
			}

			System.err.println("Time: " + (System.currentTimeMillis() - startTime) + " miliseconds");
		}

	}

	static class DisjointSetUnion {
		private int[] p;
		private int[] rank;

		public DisjointSetUnion(int n) {
			p = new int[n];
			rank = new int[n];
			for (int i = 0; i < n; ++i) {
				p[i] = i;
			}
		}

		public void merge(int x, int y) {
			int PX = find(x);
			int PY = find(y);
			if (rank[PX] > rank[PY]) p[PY] = PX;
			else p[PX] = PY;
			if (rank[PX] == rank[PY]) rank[PY] = rank[PY] + 1;

		}

		public int find(int x) {
			if (x != p[x]) p[x] = find(p[x]);
			return p[x];
		}

		public boolean same(int x, int y) {
			return find(x) == find(y);
		}

	}

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

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

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

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

	}
}

