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.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {

        new Main().solve();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.00000001;

    PrintWriter out;

    int n;
    int m;

    ArrayList<Integer>[] g = new ArrayList[2000000];

    void solve() throws IOException {

        Reader in;
        BufferedReader br;

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }

        int n = in.nextInt();
        int m = in.nextInt();

        for (int i = 0; i < n; i++)
            g[i] = new ArrayList<>();

        int loops = 0;

        int[] deg = new int[n];

        DSU dsu = new DSU(n);

        for (int i = 0; i < m; i++) {

            int x = in.nextInt()-1;
            int y = in.nextInt()-1;
            if (x == y)
                loops++;

            if (x != y) {
                deg[x]++;
                deg[y]++;
                dsu.union(x, y);
            }
        }

        long ans = 0;

        for (int i = 0; i < n; i++) {
            ans += 1l*deg[i]*(deg[i]-1)/2;
        }

        int pmax = 0;
        int a = -1;

        for (int i = 0; i < n; i++) {

            int b = dsu.get(i);
            if (dsu.size(b) > 1 && pmax > 1 && b != a) {

                System.out.println(0);
                return;
            }

            if (dsu.size(b) > 1 && a == -1) {
                pmax = dsu.size(b);
                a = b;
            }
        }

        ans += 1l*loops*(m-1);
        ans -= 1l*loops*(loops-1)/2;

        out.println(ans);
        out.flush();
        out.close();
    }

    int cnt = 0;
    boolean[] used = new boolean[1000010];

    void dfs(int v) {
        used[v] = true;
        cnt++;
        for (int u : g[v]) {
            if (!used[u])
                dfs(u);
        }
    }

    class DSU {

        int[] set;
        int[] sz;

        DSU(int n) {
            set = new int[n];
            sz = new int[n];
            for (int i = 0; i < n; i++) {
                set[i] = i;
                sz[i] = 1;
            }
        }

        int get(int a) {
            if (set[a] == a)
                return a;
            return set[a] = get(set[a]);
        }

        void union(int a, int b) {

            a = get(a);
            b = get(b);
            if (a != b) {

                if (Math.round(Math.random()) == 1) {
                    set[a] = b;
                    sz[b] += sz[a];
                }
                else {
                    set[b] = a;
                    sz[a] += sz[b];
                }

            }
        }

        int size(int a) {
            return sz[get(a)];
        }
    }

    class Pair implements Comparable<Pair>{

        long a;
        long b;


        Pair(long a, long b) {

            this.a = a;
            this.b = b;

        }

        public int compareTo(Pair p) {
            if (a > p.a) return 1;
            if (a < p.a) return -1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }


        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}