#include <bits/stdc++.h>
using namespace std;
vector<long long> a[1000006];
long long visi[1000006] = {0}, sl[1000006] = {0}, vis[1000007];
void dfs(long long node) {
  long long i;
  visi[node] = 1;
  for (i = 0; i < a[node].size(); ++i)
    if (!visi[a[node][i]]) dfs(a[node][i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, u, v, i, l = 0, ans = 0, s, f = 0;
  cin >> n >> m;
  for (i = 0; i < m; ++i) {
    cin >> u >> v;
    vis[u] = 1, vis[v] = 1;
    if (u == v) {
      l++;
      continue;
    }
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (i = 1; i <= n; ++i) {
    if (a[i].size() > 0) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!visi[i])
      if (vis[i]) return cout << 0, 0;
  }
  for (i = 1; i <= n; ++i) {
    s = a[i].size();
    ans += (s * (s - 1)) / 2;
  }
  ans += l * (m - 1) - (l * (l - 1)) / 2;
  cout << ans;
  return 0;
}
