#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 5;
int par[N], flag[N], indeg[N];
int findr(int u) {
  if (par[u] != u) par[u] = findr(par[u]);
  return par[u];
}
void unite(int a, int b) {
  int ra = findr(a), rb = findr(b);
  if (ra != rb) par[ra] = rb;
}
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    int cnt = 0;
    memset(flag, 0, sizeof(flag));
    memset(indeg, 0, sizeof(indeg));
    for (int i = 1; i <= n; i++) par[i] = i;
    for (int i = 1; i <= m; i++) {
      int a, b;
      scanf("%d", &a);
      scanf("%d", &b);
      if (a != b) {
        unite(a, b);
        indeg[a]++;
        indeg[b]++;
      } else
        flag[a] = 1, cnt++;
    }
    int ok = 1, r = 0;
    for (int i = 1; i <= n; i++)
      if (indeg[i] != 0 || flag[i]) r = findr(i);
    for (int i = 1; i <= n; i++)
      if ((indeg[i] || flag[i]) && findr(i) != r) ok = 0;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += (long long)indeg[i] * (indeg[i] - 1) / 2;
    }
    ans += (long long)cnt * (m - 1);
    ans -= (long long)cnt * (cnt - 1) / 2;
    printf("%lld\n", ok == 0 ? ok : ans);
  }
  return 0;
}
