#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * w;
}
const long long ss = 2000010;
long long fa[ss], du[ss];
inline long long find(register long long u) {
  if (u == fa[u]) return u;
  return fa[u] = find(fa[u]);
}
inline void link(register long long u, register long long v) {
  register long long xx = find(u), yy = find(v);
  if (xx != yy) fa[xx] = yy;
}
long long ans;
long long l[ss], r[ss];
long long circle;
signed main() {
  register long long n = read(), m = read();
  for (register long long i = 1; i <= n; i++) fa[i] = i;
  for (register long long i = 1; i <= m; i++) {
    l[i] = read(), r[i] = read();
    link(l[i], r[i]);
    if (l[i] == r[i])
      circle++;
    else {
      du[l[i]]++;
      du[r[i]]++;
    }
  }
  register long long begin = find(l[1]);
  for (register long long i = 2; i <= m; i++)
    if (find(l[i]) != begin) return puts("0"), 0;
  ans += (circle - 1) * circle / 2;
  ans += (circle) * (m - circle);
  for (register long long i = 1; i <= n; i++)
    ans += (long long)du[i] * (du[i] - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}
