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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class ProblemD6 {
    BufferedReader rd;

    ProblemD6() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int n = a[0];
        int m = a[1];
        Node[] e = new Node[n];
        int[] ec = new int[n];
        boolean[] loops = new boolean[n];
        long edgeCount = 0;
        int start = -1;
        for(int i=0;i<m;i++) {
            a = intarr();
            a[0]--;
            a[1]--;
            if(a[0] != a[1]) {
                edgeCount++;
                Node node = new Node();
                node.x = a[1];
                node.next = e[a[0]];
                e[a[0]] = node;
                ec[a[0]]++;
                node = new Node();
                node.x = a[0];
                node.next = e[a[1]];
                e[a[1]] = node;
                ec[a[1]]++;
            } else {
                loops[a[0]] = true;
            }
            start = a[0];
        }

        boolean[] vs = new boolean[n];
        Queue<Integer> q = new ArrayDeque<>(1000000);
        q.add(start);
        vs[start] = true;
        while(!q.isEmpty()) {
            int u = q.poll();
            Node neigh = e[u];
            while(neigh != null) {
                int v = neigh.x;
                if(!vs[v]) {
                    vs[v] = true;
                    q.add(v);
                }
                neigh = neigh.next;
            }
        }
        boolean connected = true;
        for(int i=0;i<n;i++) {
            if(!vs[i] && e[i] != null) {
                connected = false;
                break;
            }
        }
        long res = 0;
        if(connected) {
            for(int i=0;i<n;i++) {
                long s = ec[i];
                if(loops[i]) {
                    res += edgeCount;
                }
                res += s*(s-1)/2;
            }
            long s = 0;
            for(int i=0;i<n;i++) {
                if(loops[i]) {
                    s++;
                }
            }
            res += s*(s-1)/2;
        }
        out(res);
    }

    private class Node {
        int x;
        Node next;
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemD6();
    }
}
