#include <bits/stdc++.h>
int n, m;
int deg[1001101], loop;
bool f[1001101];
int p[1001101];
int get_p(int x) { return (p[x] == x) ? x : (p[x] = get_p(p[x])); }
long long calc(int sz) { return 1LL * sz * (sz - 1) / 2; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) p[i] = i;
  int block = n;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x != y) {
      deg[x]++;
      deg[y]++;
      int a = get_p(x), b = get_p(y);
      if (a != b) {
        block--;
        p[a] = b;
      }
    } else {
      loop++;
      f[x] = true;
    }
  }
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0 && !f[i]) block--;
  if (block > 1) {
    puts("0");
    return 0;
  }
  long long ans = calc(loop);
  ans += 1LL * loop * (m - loop);
  for (int i = 1; i <= n; i++) ans += calc(deg[i]);
  printf("%I64d\n", ans);
  return 0;
}
