#include <bits/stdc++.h>
using namespace std;
int const NMAX = 1000000;
int n, m;
long long v[1 + NMAX], h[1 + NMAX], rez, act;
bool a[1 + NMAX];
vector<int> aux[1 + NMAX];
int DFS(int node) {
  int c = 1;
  a[node] = true;
  for (int i = 0; i < aux[node].size(); i++) {
    if (a[aux[node][i]] == false) {
      c += DFS(aux[node][i]);
    }
  }
  return c;
}
int main() {
  std ::ios_base ::sync_with_stdio(false);
  int x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (x == y)
      h[x]++;
    else {
      aux[x].push_back(y);
      aux[y].push_back(x);
      v[x]++;
      v[y]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!a[i]) {
      int z = DFS(i);
      if (z > 1) act++;
      if (z == 1 && h[i] > 0) act++;
    }
  }
  if (act > 1) {
    cout << 0 << '\n';
    exit(EXIT_SUCCESS);
  }
  long long p = 0, s = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i] > 1) {
      act = (v[i] * (v[i] - 1)) / 2;
      rez += act;
    }
  }
  for (int i = 1; i <= n; i++) {
    p += h[i];
    s += v[i];
  }
  s /= 2;
  rez += (p * s);
  rez += (p * (p - 1)) / 2;
  cout << rez << '\n';
  return 0;
}
