#include <bits/stdc++.h>
using namespace std;
long long n, m, p[1000111], sz[1000111], deg[1000111], chk[1000111], cc;
int find(int u) { return u == p[u] ? u : (p[u] = find(p[u])); }
void merge(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return;
  p[u] = v, sz[v] += sz[u];
}
int main() {
  long long root;
  for (int i = 0; i < 1000111; i++) p[i] = i, sz[i] = 1;
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != b) deg[a]++, deg[b]++;
    if (a == b) cc++;
    chk[a] = chk[b] = 1;
    merge(a, b);
    root = find(a);
  }
  long long sum = 0;
  for (int i = 0; i <= n; i++)
    if (chk[i]) sum++;
  if (sum != sz[root]) printf("0\n"), exit(0);
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    ret += deg[i] * (deg[i] - 1) / 2LL;
  }
  ret += cc * (m - cc);
  ret += cc * (cc - 1) / 2LL;
  printf("%lld\n", ret);
}
