#include <bits/stdc++.h>
int cnt = 0;
int* array;
int f(int index) {
  if (array[index] == -1) {
    ++cnt;
    array[index] = index;
    return index;
  }
  if (array[index] == index) return index;
  int r = f(array[index]);
  array[index] = r;
  return r;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int coils = 0;
  int connect[n];
  array = connect + 0;
  int notcoils[n];
  for (int i = 0; i < n; i++) {
    connect[i] = -1;
    notcoils[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int b, e;
    scanf("%d %d", &b, &e);
    --b;
    --e;
    if (b == e) {
      if (connect[b] == -1) {
        ++cnt;
        connect[b] = b;
      }
      ++coils;
    } else {
      int rootb = f(b);
      int roote = f(e);
      if (roote != rootb) {
        --cnt;
        connect[roote] = rootb;
      }
      ++notcoils[b];
      ++notcoils[e];
    }
  }
  int notcoilsTotal = m - coils;
  if (cnt != 1) {
    printf("%d", 0);
    return 0;
  }
  long long ans = coils;
  ans = ans * (ans - 1) / 2 + notcoilsTotal * ans;
  for (int i = 0; i < n; i++) {
    long long nc = notcoils[i];
    ans += nc * (nc - 1) / 2;
  }
  std::cout << ans;
  return 0;
}
