#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); }
long long power(long long a, long long n) {
  long long p = 1;
  while (n > 0) {
    if (n & 1) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long power(long long a, long long n, long long mod) {
  long long p = 1;
  while (n > 0) {
    if (n & 1) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
vector<int> prime;
bool primee[10000000];
void primegen(long long x) {
  for (long long i = 2; i * i <= x; i++)
    if (!primee[i])
      for (long long j = i * i; j <= x; j += i) primee[j] = true;
  for (long long i = 2; i <= x; i++)
    if (!primee[i]) prime.push_back(i);
}
const int N = 1000005;
long long self_loops, adjacent_edges[N];
int pa[N], rnk[N];
void create() {
  int i;
  for (i = 1; i < N; i++) pa[i] = i, rnk[i] = 0;
}
int findpa(int x) {
  if (x != pa[x]) pa[x] = findpa(pa[x]);
  return pa[x];
}
void merge(int x, int y) {
  int xr = findpa(x);
  int yr = findpa(y);
  if (xr == yr) return;
  if (rnk[xr] < rnk[yr])
    pa[xr] = yr;
  else if (rnk[xr] > rnk[yr])
    pa[yr] = xr;
  else {
    pa[xr] = yr;
    rnk[yr]++;
  }
}
int ma[N];
int main() {
  int i, j;
  int n, m;
  create();
  scanf("%d", &n);
  scanf("%d", &m);
  int x, y, root = -1;
  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    ma[x] = ma[y] = 1;
    if (x == y)
      self_loops++;
    else {
      adjacent_edges[x]++;
      adjacent_edges[y]++;
      merge(x, y);
      root = findpa(x);
    }
  }
  for (i = 1; i < n + 1; i++)
    if (ma[i] && root != findpa(i)) {
      puts("0");
      return 0;
    }
  long long ans =
      (self_loops * (self_loops - 1)) / 2 + (self_loops * (m - self_loops));
  for (i = 1; i < n + 1; i++)
    ans += (adjacent_edges[i] * (adjacent_edges[i] - 1)) / 2;
  printf("%lld\n", ans);
  return 0;
}
