#include <bits/stdc++.h>
using namespace std;
struct uf {
  vector<int> p;
  uf(int n) : p(n, -1) {}
  int r(int x) {
    if (p[x] < 0) return x;
    return p[x] = r(p[x]);
  }
  void merge(int x, int y) {
    x = r(x);
    y = r(y);
    if (x == y) return;
    p[x] += p[y];
    p[y] = x;
  }
  int size(int x) {
    x = r(x);
    return -p[x];
  }
};
long long n, m;
long long a, b;
long long loop, dif;
long long deg[1100000];
bool exist[1100000];
int main() {
  scanf("%lld%lld", &n, &m);
  uf u(n);
  for (int i = 0; i < m; i++) {
    scanf("%lld%lld", &a, &b);
    a--, b--;
    exist[a] = exist[b] = true;
    if (a == b)
      loop++;
    else
      dif++, deg[a]++, deg[b]++;
    u.merge(a, b);
  }
  int count = 0;
  for (int i = 0; i < n; i++) count += exist[i];
  int k = 0;
  while (k < n && deg[k] == 0) k++;
  if (k == n || u.size(k) != count) {
    cout << 0 << endl;
  } else {
    long long ans = loop * (loop - 1) / 2 + loop * dif;
    for (int i = 0; i < n; i++) {
      ans += deg[i] * (deg[i] - 1) / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
