#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000011];
bool vis[1000011], one[1000011];
void dfs(int u) {
  vis[u] = 1;
  for (auto x : g[u]) {
    if (!vis[x]) {
      dfs(x);
    }
  }
}
long long c2(long long x) { return (x * (x - 1)) / 2; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, n, m, u, v;
  cin >> n >> m;
  vector<pair<int, int> > edge;
  long long self = 0;
  long long nonself = 0;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    edge.push_back({u, v});
    if (u == v) {
      one[u] = 1;
      self++;
      continue;
    }
    g[u].push_back(v);
    g[v].push_back(u);
    nonself++;
  }
  for (i = 1; i <= n; i++) {
    if (g[i].size() > 0 || one[i] == 1) {
      dfs(i);
      break;
    }
  }
  for (auto x : edge) {
    if (!vis[x.first] || !vis[x.second]) {
      cout << 0;
      return 0;
    }
  }
  long long ans = 0;
  for (i = 1; i <= n; i++) {
    ans += c2(g[i].size());
  }
  ans += c2(self);
  ans += self * nonself;
  cout << ans;
}
