#include <bits/stdc++.h>
using namespace std;
int n, m, t;
long long du[1000010];
int zh[1000010];
bool vis[1000010];
int tot, head[1000010], nxt[1000010 << 1], to[1000010 << 1];
inline void add(int x, int y) {
  to[++tot] = y;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dfs(int u) {
  vis[u] = true;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
    if (x == y) {
      t++;
      zh[x]++;
      continue;
    }
    du[x]++, du[y]++;
  }
  for (int i = 1; i <= n; i++)
    if (du[i]) {
      dfs(i);
      break;
    }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      if (du[i] || zh[i]) {
        printf("0\n");
        return 0;
      }
    }
  long long ans = 0;
  ans += (long long)t * (t - 1) / 2;
  ans += (long long)t * (m - t);
  for (int i = 1; i <= n; i++)
    if (du[i] >= 2) ans += (long long)du[i] * (du[i] - 1) / 2;
  printf("%lld", ans);
}
