#include <bits/stdc++.h>
using namespace std;
long long int n, m, par[1000001], ct[1000001], ctl[1000001];
long long int par_find(long long int v) {
  return par[v] == v ? par[v] : par[v] = par_find(par[v]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long int i = 1; i <= n; ++i) par[i] = i;
  for (long long int i = 1; i <= m; ++i) {
    long long int u, v;
    cin >> u >> v;
    if (u == v)
      ctl[u]++;
    else
      ct[u]++, ct[v]++;
    u = par_find(u);
    v = par_find(v);
    par[u] = v;
  }
  long long int ch = 0;
  for (long long int i = 1; i <= n; ++i)
    if (par[i] == i && (ct[i] || ctl[i])) ch++;
  if (ch != 1) {
    cout << 0 << '\n';
    return 0;
  }
  long long int totc = 0, tot = 0;
  for (long long int i = 1; i <= n; ++i) tot += ct[i], totc += ctl[i];
  tot /= 2;
  long long int ans = (totc * (totc - 1)) / 2;
  ans += totc * tot;
  for (long long int i = 1; i <= n; ++i) ans += (ct[i] * (ct[i] - 1)) / 2;
  cout << ans << '\n';
}
