#include <bits/stdc++.h>
using namespace std;
long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
long long pre[maxn], deg[maxn], loop[maxn], totLoop;
inline long long root(long long x) {
  return pre[x] == x ? x : pre[x] = root(pre[x]);
}
inline long long c2(long long x) { return x * (x - 1) / 2; }
inline void merge(long long a, long long b) {
  a = root(a), b = root(b);
  if (a == b) return;
  pre[a] = b;
}
int32_t main() {
  long long n = in(), m = in();
  iota(pre, pre + n, 0);
  for (long long i = 0; i < m; i++) {
    long long v = in() - 1, u = in() - 1;
    deg[v]++, deg[u]++;
    if (v == u) loop[v]++, totLoop++;
    merge(v, u);
  }
  long long Tot = 0;
  for (long long i = 0; i < n; i++) {
    Tot += (pre[i] == i && bool(deg[i]));
  }
  if (Tot > 1) return cout << 0 << endl, 0;
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    res += c2(deg[i] - 2 * loop[i]);
  }
  res += c2(totLoop) + totLoop * (m - totLoop);
  cout << res << endl;
}
