#include <bits/stdc++.h>
using namespace std;
const int L = 1 << 20;
char buffer[L], *S, *T;
inline long long read() {
  long long s = 0, f = 1;
  char ch = (S == T && (T = (S = buffer) + fread(buffer, 1, L, stdin), S == T)
                 ? EOF
                 : *S++);
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = (S == T && (T = (S = buffer) + fread(buffer, 1, L, stdin), S == T)
              ? EOF
              : *S++);
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = (S == T && (T = (S = buffer) + fread(buffer, 1, L, stdin), S == T)
              ? EOF
              : *S++);
  }
  return s * f;
}
const long long maxn = 1e6 + 10;
long long rd[maxn];
long long flag[maxn];
long long vis[maxn];
struct Node {
  long long v, next;
} e[maxn << 1];
long long head[maxn], tot;
void Add(long long x, long long y) {
  e[++tot].v = y;
  e[tot].next = head[x];
  head[x] = tot;
}
inline void dfs(long long x) {
  vis[x] = 1;
  for (long long i = head[x]; i; i = e[i].next) {
    long long v = e[i].v;
    if (!vis[v]) dfs(v);
  }
}
signed main() {
  long long cnt = 0;
  long long n = read(), m = read();
  for (long long i = 1; i <= m; ++i) {
    long long x = read(), y = read();
    Add(x, y);
    Add(y, x);
    if (x == y) flag[x]++, cnt++;
    if (x != y) {
      rd[x]++;
      rd[y]++;
    }
  }
  long long ans = -cnt * (cnt - 1) / 2;
  for (long long i = 1; i <= n; ++i) {
    if (rd[i]) {
      dfs(i);
      break;
    }
  }
  for (long long i = 1; i <= n; ++i) {
    if (!vis[i] && head[i]) return puts("0"), 0;
  }
  for (long long i = 1; i <= n; ++i) {
    ans += (long long)rd[i] * (long long)(rd[i] - 1) / 2;
    ans += (long long)flag[i] * (long long)(m - 1);
  }
  printf("%lld\n", ans);
}
