#include <bits/stdc++.h>
using namespace std;
void scanint(int &x) {
  register int c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
const int N = 1000006;
vector<int> v[N];
bool visited[N], mark[N], flag;
int parent[N];
void dfs(int u) {
  int pt;
  for (int i = 0; i < v[u].size(); i++) {
    pt = v[u][i];
    if (!visited[pt]) {
      flag = true;
      visited[pt] = true;
      dfs(pt);
    }
    if (mark[pt]) {
      flag = true;
    }
  }
  return;
}
int main() {
  int n, m, a, b, cnt = 0;
  long long self = 0LL;
  scanint(n);
  scanint(m);
  for (int i = 1; i <= m; i++) {
    scanint(a);
    scanint(b);
    if (a == b) {
      v[a].push_back(a);
      self++;
      mark[a] = true;
    } else {
      v[a].push_back(b);
      v[b].push_back(a);
    }
  }
  long long answer = 0LL, sz;
  for (int i = 1; i <= n; i++) {
    sz = v[i].size();
    if (mark[i]) {
      sz--;
    }
    answer = answer + ((sz * (sz - 1LL)) / 2LL);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      flag = false;
      visited[i] = true;
      parent[i] = i;
      dfs(i);
      if (flag) {
        cnt++;
        if (cnt > 1) break;
      }
    }
  }
  if (cnt != 1) {
    printf("0\n");
    return 0;
  }
  answer = answer + self * ((long long)m - 1LL) - ((self * (self - 1LL)) / 2LL);
  printf("%lld\n", answer);
  return 0;
}
