#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int f = 1, x = 0;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return f * x;
}
const int MAXINT = 1000010;
int cnt, n, m, fa[MAXINT], bl, apr[MAXINT];
unsigned long long ds[MAXINT];
unsigned long long cnt_sc = 0;
struct edge {
  edge *next;
  int u, v;
  edge() {}
  edge(int _u, int _v, edge *_next) : u(_u), v(_v), next(_next) {}
} * head[MAXINT], e[MAXINT * 2];
void add_edge(int u, int v) {
  e[cnt] = edge(u, v, head[u]);
  head[u] = &e[cnt++];
  e[cnt] = edge(v, u, head[v]);
  head[v] = &e[cnt++];
}
int find_f(int p) { return fa[p] == p ? p : fa[p] = find_f(fa[p]); }
void get_input() {
  cnt = 0;
  n = read();
  m = read();
  int u, v;
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 0; i < m; ++i) {
    u = read();
    v = read();
    add_edge(u, v);
    apr[u] = apr[v] = 1;
    if (u == v)
      cnt_sc++;
    else {
      ds[u]++;
      ds[v]++;
    }
    fa[find_f(v)] = find_f(u);
  }
}
void work() {
  unsigned long long ans = 0;
  bl = -1;
  for (int i = 1; i <= n; i++) {
    if (apr[i] && bl != find_f(i)) {
      if (bl == -1) {
        bl = find_f(i);
        continue;
      }
      printf("0\n");
      return;
    }
  }
  for (int i = 1; i <= n; ++i) {
    ans += (long long)(ds[i]) * (ds[i] - 1) / 2;
  }
  ans += cnt_sc * (m - cnt_sc) + (cnt_sc) * (cnt_sc - 1) / 2;
  printf("%I64u", ans);
}
int main() {
  get_input();
  work();
  return 0;
}
