#include <bits/stdc++.h>
using namespace std;
int pre[2100000], now[1100000], son[2100000], tot, no[2100000];
int zh[1100000], n, m;
void con(int a, int b, int k) {
  pre[++tot] = now[a];
  son[tot] = b;
  now[a] = tot;
  no[tot] = k;
}
bool bb[1100000], link[1100000];
int line[2100000], degree[1100000], start, selfloop, edge;
void bfs() {
  int head = 0, tail = 1;
  line[1] = start;
  do {
    int x = line[++head];
    for (int p = now[x]; p; p = pre[p]) {
      link[no[p]] = 1;
      if (!bb[son[p]]) {
        bb[son[p]] = 1;
        line[++tail] = son[p];
      }
    }
  } while (head != tail);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != b) {
      degree[a]++;
      degree[b]++;
      con(a, b, i);
      con(b, a, i);
      edge++;
    } else {
      selfloop++;
      con(a, a, i);
    }
    start = a;
  }
  bfs();
  for (int i = 1; i <= m; i++)
    if (!link[i]) {
      puts("0");
      return 0;
    }
  long long ans = 1LL * selfloop * edge + 1LL * selfloop * (selfloop - 1) / 2;
  for (int i = 1; i <= n; i++) {
    ans += 1LL * degree[i] * (degree[i] - 1) / 2;
  }
  printf("%I64d\n", ans);
}
