#include <bits/stdc++.h>
using namespace std;
long long p[1000003];
long long ind[1000003];
bool l[1000003];
long long Find(long long a) {
  if (a == p[a]) return a;
  return p[a] = Find(p[a]);
}
void Union(long long a, long long b) {
  if (Find(a) == Find(b)) return;
  p[Find(a)] = p[Find(b)];
}
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i <= n; i++) p[i] = i;
  long long loop = 0;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    scanf("%lld %lld", &a, &b);
    if (a == b)
      loop++, l[a] = true;
    else
      ind[a]++, ind[b]++, Union(a, b);
  }
  long long cnt = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    ans += ind[i] * (ind[i] - 1) / 2;
    if (p[i] == i) cnt++;
    if (ind[i] == 0 && !l[i]) cnt--;
  }
  if (cnt != 1)
    printf("0");
  else {
    ans += loop * (m - loop);
    ans += loop * (loop - 1) / 2;
    printf("%lld", ans);
  }
}
