#include <bits/stdc++.h>
using namespace std;
const int MAX = 1 << 20;
int bio[MAX];
vector<int> V[MAX];
int a[MAX], b[MAX];
int deg[MAX];
void dfs(int x) {
  if (bio[x]++) return;
  for (auto it : V[x]) dfs(it);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int usebe = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
    V[a[i]].push_back(b[i]);
    V[b[i]].push_back(a[i]);
    if (a[i] == b[i])
      usebe++;
    else {
      deg[a[i]]++;
      deg[b[i]]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (V[i].size()) {
      dfs(i);
      break;
    }
  }
  for (int i = 0; i < n; i++)
    if (!bio[i] && V[i].size()) {
      printf("0\n");
      return 0;
    }
  long long rje = 0;
  rje += (long long)usebe * (usebe - 1) / 2;
  rje += (long long)usebe * (m - usebe);
  for (int i = 0; i < n; i++) rje += (long long)deg[i] * (deg[i] - 1) / 2;
  printf("%lld\n", rje);
  return 0;
}
