#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long n, m;
vector<long long> e[1000069];
long long deg[1000069], loops;
bitset<1000069> vis, has, is_loop;
void dfs(int i) {
  if (vis[i]) return;
  vis.set(i);
  for (long long v : e[i]) dfs(v);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  long long u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--, v--;
    has.set(u), has.set(v);
    e[u].push_back(v);
    e[v].push_back(u);
    if (u == v)
      deg[u]++, loops++, is_loop.set(u);
    else
      deg[u]++, deg[v]++;
  }
  dfs(u);
  if (vis.count() != has.count()) return cout << "0\n", 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += deg[i] * (deg[i] - 1) / 2;
    if (is_loop[i]) ans += m - deg[i];
  }
  ans -= loops * (loops - 1) / 2;
  cout << ans << '\n';
}
