#include <bits/stdc++.h>
using namespace std;
const long long mx = 1e6 + 5;
long long n, cnt, l, sum, m, k, s[mx];
vector<long long> adj[mx];
bool mark[mx];
void dfs(long long v) {
  mark[v] = 1;
  cnt++;
  long long t = adj[v].size();
  sum += t * (t - 1) / 2;
  for (long long i = 0; i < adj[v].size(); i++) {
    long long u = adj[v][i];
    if (!mark[u]) {
      dfs(u);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  long long nn = n;
  for (long long i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u;
    if (v == u)
      s[v]++;
    else {
      adj[v].push_back(u), adj[u].push_back(v);
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (adj[i].size()) {
      k = i;
    } else {
      nn--;
    }
  }
  dfs(k);
  for (long long i = 1; i <= n; i++) {
    if (mark[i]) l += s[i];
    if (!mark[i] && s[i]) return cout << 0 << endl, 0;
  }
  if (cnt < nn) return cout << 0 << endl, 0;
  if (l) sum += l * (l - 1) / 2;
  sum += (m - l) * l;
  cout << sum << endl;
  return 0;
}
