#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000005];
bool f[1000005];
int stk[1000005];
int deg[1000005];
int m, n;
bool connected() {
  int s = 0;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0)
      f[i] = true;
    else
      s = i;
  int top = 0;
  stk[top] = s;
  f[s] = true;
  while (top >= 0) {
    int u = stk[top--];
    for (int i = 0; i < g[u].size(); i++)
      if (!f[g[u][i]]) {
        stk[++top] = g[u][i];
        f[g[u][i]] = true;
      }
  }
  for (int i = 1; i <= n; i++)
    if (!f[i]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  long long ans = 0;
  cin >> n >> m;
  int l = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    deg[u]++;
    deg[v]++;
    if (u == v)
      l++;
    else {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  if (connected()) {
    for (int i = 1; i <= n; i++) {
      int k = g[i].size();
      ans += 1LL * k * (k - 1) / 2;
    }
    ans += 1LL * l * (l - 1) / 2 + 1LL * l * (m - l);
  }
  cout << ans << '\n';
}
