#include <bits/stdc++.h>
using namespace std;
long long cnt, ans, cnt1, cnt2, poi[2000050], vis[2000050], q[2000050],
    nxt[2000050], f[2000050], n, m, x, y, num[2000050];
bool bj[2000050];
inline void add(long long x, long long y) {
  poi[++cnt] = y;
  nxt[cnt] = f[x];
  f[x] = cnt;
}
inline void BFS(int x) {
  long long l = 1, r = 1;
  q[1] = x;
  vis[x] = 1;
  while (l <= r) {
    long long x = q[l];
    for (long long i = f[x]; i; i = nxt[i])
      if (!vis[poi[i]]) vis[poi[i]] = 1, q[++r] = poi[i];
    l++;
  }
  for (long long i = 1; i <= n; i++)
    if (!vis[i] && bj[i]) {
      puts("0");
      exit(0);
    }
}
int main() {
  scanf("%lld%lld", &n, &m);
  long long s;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    bj[x] = bj[y] = 1;
    s = x;
    if (x == y)
      cnt1++;
    else {
      cnt2++;
      add(x, y);
      add(y, x);
      num[x]++;
      num[y]++;
    }
  }
  BFS(s);
  for (long long i = 1; i <= n; i++)
    if (!vis[i] && bj[i]) {
      puts("0");
      return 0;
    }
  ans = cnt1 * cnt2 + (cnt1 * cnt1 - cnt1) / 2;
  for (long long i = 1; i <= n; i++) ans += num[i] * (num[i] - 1) / 2;
  printf("%I64d", ans);
}
