#include <bits/stdc++.h>
using namespace std;
const long long UNDEF = -1;
const long long INF = 1e18;
template <typename T>
inline bool chkmax(T &aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T &aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
const int mn = 1e6 + 4;
bool seen[mn];
vector<int> g[mn];
bool care[mn];
void dfs(int x) {
  if (seen[x]) return;
  seen[x] = true;
  for (auto &y : g[x]) {
    if (!seen[y]) dfs(y);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  memset(care, 0, sizeof care);
  int cared = -1;
  long long self = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    care[u] = true;
    care[v] = true;
    cared = u;
    if (u != v) {
      g[u].push_back(v);
      g[v].push_back(u);
    } else
      self++;
  }
  memset(seen, 0, sizeof seen);
  dfs(cared);
  bool ok = true;
  for (int x = 1; x <= n; x++)
    if (care[x] && (!seen[x])) ok = false;
  if (!ok) {
    printf("0\n");
    return 0;
  }
  long long ans = 0;
  for (int x = 1; x <= n; x++) {
    if (care[x]) {
      long long s = g[x].size();
      ans += (s * (s - 1)) / 2;
    }
  }
  ans += (m - self) * self;
  ans += (self * (self - 1)) / 2;
  printf("%lld\n", ans);
}
