#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> G[maxn];
int roop, edges, vispoint, deg[maxn], n, deg1, cnt[maxn], tot;
bool vis[maxn];
bool book[maxn];
bool dfs(int u) {
  if (!vis[u]) vis[u] = true, vispoint++;
  if (vispoint == tot) return true;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (deg[v] == 1) cnt[u]++;
    if (!vis[v]) {
      if (dfs(v)) return true;
    }
  }
  return false;
}
int main() {
  int m, u, v;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 1; i <= n; i++)
      if (G[i].size()) G[i].clear();
    deg1 = 0;
    edges = 0;
    roop = 0;
    vispoint = 0;
    memset(deg, 0, sizeof(deg));
    memset(vis, false, sizeof(vis));
    memset(book, false, sizeof(book));
    memset(cnt, 0, sizeof(cnt));
    tot = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      if (!book[u]) book[u] = true, tot++;
      if (!book[v]) book[v] = true, tot++;
      if (u == v)
        roop++;
      else {
        deg[u]++, deg[v]++;
        G[u].push_back(v);
        G[v].push_back(u);
      }
    }
    if (!dfs(u)) {
      puts("0");
      continue;
    }
    long long sum = 0;
    for (int i = 1; i <= n; i++) sum += (long long)deg[i] * (deg[i] - 1) / 2;
    sum += (long long)roop * (m - roop) + (long long)roop * (roop - 1) / 2;
    printf("%I64d\n", sum);
  }
}
