#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch > '9' || ch < '0');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch <= '9' && ch >= '0');
  return f * x;
}
const int maxn = 1e6 + 7;
long long res;
int n, m, a[maxn], b[maxn], fa[maxn], x[maxn], cnt;
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 0; i < m; i++) {
    a[i] = read();
    b[i] = read();
    fa[find(a[i])] = find(b[i]);
    if (a[i] == b[i])
      cnt++;
    else
      x[a[i]]++, x[b[i]]++;
  }
  for (int i = 1, k = find(a[0]); i < m; i++)
    if (find(a[i]) != k) return 0 * puts("0");
  for (int i = 1; i <= n; i++) res += 1LL * x[i] * (x[i] - 1) / 2;
  res += 1LL * cnt * (m - cnt) + 1LL * cnt * (cnt - 1) / 2;
  printf("%lld\n", res);
}
