#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<bool> vis;
void dfs(int u) {
  vis[u] = true;
  for (int v : adj[u]) {
    if (!vis[v]) {
      dfs(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  adj = vector<vector<int>>(n);
  vis = vector<bool>(n, false);
  vector<bool> self_ad(n, false);
  int i, j;
  int u, v;
  long long smc = 0;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    if (u != v) {
      adj[u].push_back(v);
      adj[v].push_back(u);
    } else {
      smc++;
      self_ad[u] = true;
    }
  }
  int cc = 0;
  for (i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
      if (adj[i].size() != 0 || self_ad[i]) {
        cc++;
      }
    }
  }
  long long ans = 0;
  if (cc == 1) {
    for (i = 0; i < n; i++) {
      long long s = adj[i].size();
      ans += (s * (s - 1)) / 2;
    }
    ans += (smc * (smc - 1)) / 2;
    ans += smc * (m - smc);
  }
  cout << ans;
  return 0;
}
