#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 10;
int r[N], sz[N], chk[N];
int o;
int find(int x) {
  if (x == r[x]) return x;
  return r[x] = find(r[x]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) r[i] = i;
  int cnt = 0, cur = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    chk[u] = chk[v] = 1;
    if (u == v)
      ++o;
    else
      sz[u]++, sz[v]++;
    int x = find(u), y = find(v);
    if (x != y) r[x] = y, cnt++;
  }
  set<int> se;
  for (int i = 1; i <= n; i++) {
    if (chk[i]) {
      se.insert(find(i));
    }
  }
  if (se.size() > 1) {
    puts("0");
    return 0;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1LL * sz[i] * (sz[i] - 1) / 2;
  }
  ans += 1LL * o * (o - 1) / 2;
  ans += 1LL * o * (m - o);
  cout << ans << endl;
}
