#include <bits/stdc++.h>
using namespace std;
const int MN = 1e6 + 100;
int d[MN];
bool mark[MN];
vector<int> adj[MN];
int dfs(int v) {
  mark[v] = true;
  int ret = 0;
  for (int u : adj[v]) {
    ret++;
    if (!mark[u]) {
      ret += dfs(u);
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  int n, m, lp = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    if (u != v) {
      adj[v].push_back(u);
      d[v]++;
      d[u]++;
    } else {
      lp++;
    }
  }
  bool f = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      int cnt = dfs(i);
      if (cnt > 0 && f) {
        cout << 0;
        return 0;
      }
      if (cnt > 0) {
        f = 1;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += 1ll * d[i] * (d[i] - 1) / 2;
  }
  ans += 1ll * lp * (lp - 1) / 2 + 1ll * lp * (m - lp);
  cout << ans;
}
