#include <bits/stdc++.h>
inline long long read() {
  long long x = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * fh;
}
const long long maxn = 3e6 + 5;
long long n, m, rd[maxn], cntt, cnt[maxn], fa[maxn], anss[maxn];
long long ans = 0;
long long zhao(long long xx) {
  if (xx == fa[xx]) return xx;
  return fa[xx] = zhao(fa[xx]);
}
void bing(long long xx, long long yy) { fa[zhao(xx)] = zhao(yy); }
signed main() {
  n = read(), m = read();
  for (long long i = 1; i <= n; i++) {
    fa[i] = i;
  }
  for (long long i = 1; i <= m; i++) {
    long long aa, bb;
    aa = read(), bb = read();
    if (aa == bb) {
      cnt[aa]++;
      cntt++;
      continue;
    }
    bing(aa, bb);
    rd[aa]++;
    rd[bb]++;
  }
  for (long long i = 1; i <= n; i++) {
    anss[zhao(i)] += rd[i];
    anss[zhao(i)] += cnt[i] * 2;
  }
  for (long long i = 1; i <= n; i++) {
    if (anss[i] == 0 || anss[i] == m * 2) continue;
    printf("0\n");
    return 0;
  }
  for (long long i = 1; i <= n; i++) {
    if (rd[i] >= 2) {
      ans += 1LL * (rd[i] - 1) * rd[i] / 2LL;
    }
  }
  ans += cntt * (m - cntt);
  ans += 1LL * (cntt - 1) * cntt / 2LL;
  printf("%lld\n", ans);
  return 0;
}
