#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000100];
int dfsT[1000100];
int dt = 1;
int num[1000100];
int numX[1000100];
void dfs(int u) {
  dfsT[u] = dt++;
  for (auto v : g[u]) {
    if (!dfsT[v]) dfs(v);
  }
}
int main() {
  int l = 0;
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    if (u != v) {
      num[u]++;
      num[v]++;
    } else {
      numX[u]++;
      l++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (num[i] || numX[i]) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!dfsT[i] && (num[i] || numX[i])) {
      printf("0\n");
      return 0;
    }
  }
  long long sol = 0;
  for (int i = 1; i <= n; i++) {
    sol += 1ll * (1ll * num[i]) * (1ll * num[i] - 1) / 2;
    sol += 1ll * numX[i] * (1ll * m - l);
  }
  sol += 1ll * l * (1ll * l - 1) / 2;
  printf("%lld\n", sol);
  return 0;
}
