#include <bits/stdc++.h>
using namespace std;
int N, M;
int dad[1000006];
int deg[1000006];
int self[1000006];
int anc(int u) {
  if (dad[u] == u) return u;
  return dad[u] = anc(dad[u]);
}
void join(int u, int v) { dad[anc(v)] = anc(u); }
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = (1), _b = (N); i <= _b; i++) dad[i] = i;
  int u, v;
  for (int i = (1), _b = (M); i <= _b; i++) {
    cin >> u >> v;
    if (u == v) {
      ++self[u];
      continue;
    }
    ++deg[u];
    ++deg[v];
    join(u, v);
  }
  int cc = 0;
  for (int i = (1), _b = (N); i <= _b; i++)
    if ((deg[i] + self[i]) && dad[i] == i) ++cc;
  if (cc > 1) return cout << 0 << endl, 0;
  long long ans = 0;
  int Self = 0;
  for (int i = (1), _b = (N); i <= _b; i++) Self += self[i];
  for (int i = (1), _b = (N); i <= _b; i++)
    ans += 1ll * deg[i] * (deg[i] - 1) / 2;
  ans += 1ll * Self * (M - Self);
  ans += 1ll * Self * (Self - 1) / 2;
  cout << ans << endl;
  return 0;
}
