#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int d[N], n, m, cntlp;
bool loop[N], mark[N];
long long ans;
vector<int> adj[N];
void input() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    if (u == v) {
      loop[u] = true;
      cntlp++;
    } else {
      d[u]++, d[v]++;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
  }
}
void dfs(int u = 0) {
  mark[u] = true;
  for (auto v : adj[u]) {
    if (!mark[v]) {
      dfs(v);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  input();
  for (int i = 0; i < n; i++) {
    if (d[i] || loop[i]) {
      dfs(i);
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!mark[i] && (d[i] || loop[i])) {
      cout << 0;
      return 0;
    }
    if (d[i] > 1) {
      ans += 1LL * d[i] * (d[i] - 1) / 2;
    }
    if (loop[i]) {
      ans += m - cntlp;
    }
  }
  if (cntlp > 1) {
    ans += 1LL * cntlp * (cntlp - 1) / 2;
  }
  cout << ans;
  return 0;
}
