#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000000 + 10;
int head[maxn], deg[maxn], fa[maxn], buf[maxn], vis[maxn], is_cer[maxn];
long long ans;
struct node {
  int to, next;
} edge[maxn << 1];
int cnt, n, m, cnm;
void add(int from, int to) {
  edge[++cnt].to = to;
  edge[cnt].next = head[from];
  head[from] = cnt;
}
int find(int x) { return x == fa[x] ? x : (fa[x] = find(fa[x])); }
void merge(int x, int y) { fa[find(x)] = find(y); }
void Solve() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    vis[x] = vis[y] = 1;
    if (x == y) {
      is_cer[x]++;
      continue;
    }
    add(x, y);
    add(y, x);
    deg[x]++;
    deg[y]++;
    merge(x, y);
  }
  for (int i = 1; i <= n; ++i)
    if (vis[i]) buf[find(i)] = 1;
  int tool = 0;
  for (int i = 1; i <= n; ++i)
    if (buf[i]) tool++;
  if (tool > 1) {
    printf("0");
    return;
  }
  for (int i = 1; i <= n; ++i) ans += ((long long)deg[i] * (deg[i] - 1)) >> 1;
  for (int i = 1; i <= n; ++i) cnm += is_cer[i];
  long long res = ((long long)(cnm + cnt - 1) * cnm) >> 1;
  if (cnm) ans += res;
  printf("%lld", ans);
}
int main() {
  Solve();
  return 0;
}
