#include <bits/stdc++.h>
using namespace std;
struct edge {
  int t, next;
} g[2100001];
long long ans;
int h[1100001], deg[1100001], i, j, k, n, m, v[1100001], vi, vl, tot, num,
    lp[1100001];
void addedge(int x, int y) {
  g[++tot].t = y;
  g[tot].next = h[x];
  h[x] = tot;
  deg[x]++;
  g[++tot].t = x;
  g[tot].next = h[y];
  h[y] = tot;
  deg[y]++;
}
void dfs(int x) {
  int i;
  num++;
  v[x] = 1;
  for (i = h[x]; i; i = g[i].next)
    if (!v[g[i].t]) dfs(g[i].t);
}
int main() {
  scanf("%d%d", &n, &m);
  memset(deg, 0, sizeof(deg));
  memset(v, 0, sizeof(v));
  memset(lp, 0, sizeof(lp));
  tot = vl = vi = 0;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    if (j != k)
      addedge(j, k);
    else
      lp[j] = 1, vl++;
  }
  for (i = 1; i <= n; i++)
    if (!deg[i] && !lp[i]) vi++;
  for (i = 1; !deg[i] && !lp[i]; i++)
    ;
  num = 0;
  dfs(i);
  if (num != n - vi) {
    puts("0");
    return 0;
  }
  for (ans = 0, i = 1; i <= n; i++)
    ans += (long long)deg[i] * (long long)(deg[i] - 1) / 2LL;
  ans += (long long)vl * (long long)(vl - 1) / 2LL;
  ans += (long long)vl * (long long)(m - vl);
  cout << ans << endl;
  return 0;
}
