#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
long long u[1000003], v[1000003];
vector<long long> e[1000003];
bool f[1000003];
void dfs(long long x) {
  f[x] = 1;
  for (long long y : e[x])
    if (!f[y]) dfs(y);
}
long long deg[1000003];
signed main() {
  long long n = read(), m = read(), C = 0;
  for (long long i = 1; i <= m; i++) {
    u[i] = read(), v[i] = read(), ++deg[u[i]], ++deg[v[i]],
    e[u[i]].push_back(v[i]), e[v[i]].push_back(u[i]);
    if (u[i] == v[i]) deg[u[i]] -= 2, ++C;
  }
  for (long long i = 1; i <= n; i++)
    if (!e[i].empty()) {
      dfs(i);
      break;
    }
  for (long long i = 1; i <= n; i++)
    if ((!e[i].empty()) && (!f[i])) puts("0"), exit(0);
  long long ans = C * (m - C);
  ans += C * (C - 1) / 2;
  for (long long i = 1; i <= n; i++) ans += deg[i] * (deg[i] - 1) / 2;
  printf("%lld\n", ans);
  return 0;
}
