#include <bits/stdc++.h>
using namespace std;
const int dx4[5] = {0, -1, 0, 1, 0};
const int dy4[5] = {0, 0, 1, 0, -1};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int maxn = 1e6 + 5;
const double PI = acos(-1.0);
const long long mod = 1e9 + 7;
long long po(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
void YES() {
  puts("YES");
  exit(0);
}
void Yes() {
  puts("Yes");
  exit(0);
}
void NO() {
  puts("NO");
  exit(0);
}
void No() {
  puts("No");
  exit(0);
}
void one() {
  puts("-1");
  exit(0);
}
int n, m;
int fa[maxn];
int v1[maxn], v2[maxn];
set<int> edge[maxn];
int getfa(int x) { return x == fa[x] ? x : fa[x] = getfa(fa[x]); }
void solve() {
  scanf("%d", &(n)), scanf("%d", &(m));
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &(v1[i])), scanf("%d", &(v2[i]));
    int k1 = getfa(v1[i]);
    int k2 = getfa(v2[i]);
    if (k1 != k2) {
      fa[k1] = k2;
    }
  }
  int k = getfa(v1[1]);
  for (int i = 1; i <= m; i++) {
    int x = getfa(v1[i]);
    int y = getfa(v2[i]);
    if (x != k || y != k) {
      puts("0");
      return;
    }
  }
  long long cnt = 0;
  for (int i = 1; i <= m; i++) {
    if (v1[i] == v2[i]) {
      cnt++;
      continue;
    }
    edge[v1[i]].insert(v2[i]);
    edge[v2[i]].insert(v1[i]);
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    long long sz = edge[i].size();
    res += sz * (sz - 1) / 2;
  }
  res += 1LL * cnt * (cnt - 1) / 2;
  res += 1LL * cnt * (m - cnt);
  printf("%lld\n", res);
}
int main() {
  solve();
  return 0;
}
