#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000006];
bool b[1000006], k[1000006], d[1000006];
int main() {
  ios::sync_with_stdio(false);
  int n, m, u, v, c = 1, l = 0;
  long long int z = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    d[u] = d[v] = 1;
    g[u].push_back(v);
    if (u != v)
      g[v].push_back(u);
    else
      k[u] = 1, l++;
  }
  queue<int> q;
  int ii = 0;
  for (int i = 1; i <= n; i++)
    if (d[i]) ii = i;
  q.push(ii);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i : g[x])
      if (!b[i]) q.push(i), b[i] = 1;
  }
  bool yy = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] && !b[i]) yy = 1;
  if (yy)
    cout << 0;
  else {
    for (int i = 1; i <= n; i++)
      z += (long long int)g[i].size() * (g[i].size() - 1) / 2;
    for (int i = 1; i <= n; i++)
      if (k[i]) z += m - l - g[i].size() + 1;
    cout << z + (long long int)l * (l - 1) / 2;
  }
}
