#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 400010;
vector<int> G[1000100];
const int mod = 1e9 + 7;
int num[1000100], p[1000100];
bool leap[1000100], self[1000100];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    num[i] = 1;
  }
}
int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }
long long pow_mod(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ans;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(leap, false, sizeof(leap));
  memset(self, false, sizeof(self));
  init(n);
  long long count = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v) {
      count++;
      self[u] = true;
      continue;
    }
    G[u].push_back(v);
    G[v].push_back(u);
    int fx = find(u);
    int fy = find(v);
    if (fx == fy) continue;
    p[fx] = fy;
    num[fy] += num[fx];
  }
  bool ok = true;
  int root = -1;
  for (int u = 1; u <= n; u++) {
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      int x = find(u);
      if (root == -1)
        root = x;
      else if (root != x)
        ok = false;
    }
    if (self[u]) {
      int x = find(u);
      if (root == -1)
        root = x;
      else if (root != x)
        ok = false;
    }
  }
  if (!ok) {
    printf("0\n");
    return 0;
  }
  long long ans = 0;
  ans = ans + count * (m - count) * 2;
  ans = ans + count * (count - 1);
  for (int u = 1; u <= n; u++) {
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (v < u) continue;
      ans = (ans + G[v].size() - 1 + G[u].size() - 1);
    }
  }
  ans = ans / 2;
  printf("%I64d\n", ans);
  return 0;
}
