#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, m, d[N], c, vis[N], sum;
vector<long long> g[N];
void dfs(long long p) {
  ++sum;
  vis[p] = 1;
  for (long long q : g[p]) {
    if (vis[q] == 0) dfs(q);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  unordered_set<long long> s;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    s.insert(u);
    s.insert(v);
    if (u == v) {
      ++c;
      continue;
    }
    g[u].push_back(v);
    g[v].push_back(u);
    d[u]++;
    d[v]++;
  }
  dfs(*s.begin());
  if (sum < s.size()) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++)
    if (d[i]) ans += (d[i] - 1) * d[i] / 2;
  ans += c * (m - c);
  if (c) ans += c * (c - 1) / 2;
  cout << ans << endl;
}
