#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> us;
void dfs(int v) {
  us[v] = 1;
  for (int i : g[v]) {
    if (!us[i]) dfs(i);
  }
  return;
}
int main() {
  iostream::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> st(n);
  g.resize(n);
  us.resize(n, 0);
  vector<int> self(n);
  long long cn = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (x != y) {
      st[x]++;
      st[y]++;
    } else {
      self[x] = 1;
      cn++;
    }
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int start = 0;
  while (st[start] == 0 && !self[start]) start++;
  dfs(start);
  for (int i = 0; i < n; i++) {
    if (!us[i] && (st[i] || self[i])) {
      cout << 0;
      return 0;
    }
  }
  long long ans = 0;
  for (long long x : st) {
    ans += (x * (x - 1)) / 2;
  }
  cout << ans + cn * (m - cn) + (cn * (cn - 1)) / 2;
  return 0;
}
