#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
vector<int> v[MAX];
int d[MAX], pa[MAX];
bool vis[MAX];
int find(int x) {
  if (pa[x] == x) return x;
  return pa[x] = find(pa[x]);
}
void ini() {
  int i;
  for (i = 1; i < MAX; i++) d[i] = 0, pa[i] = i, vis[i] = false;
}
int main() {
  ini();
  int n, m, i, loops = 0;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    vis[x] = vis[y] = true;
    if (x == y)
      loops++;
    else {
      d[x]++, d[y]++;
      pa[find(x)] = find(y);
    }
  }
  int temp = 0;
  for (i = 1; i <= n; i++) {
    if (pa[i] == i && vis[i]) temp++;
  }
  if (temp >= 2)
    printf("0\n");
  else {
    long long int ans = 0;
    for (i = 1; i <= n; i++) ans += (d[i] * 1LL * (d[i] - 1) / 2);
    ans += (loops * 1LL * (m - loops));
    ans += (loops * 1LL * (loops - 1) / 2);
    printf("%lld\n", ans);
  }
  return 0;
}
