#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000100;
vector<int> A[MAX_N];
bool viz[MAX_N];
int l[MAX_N];
long long ans;
int loops;
int edges;
void dfs(int nod) {
  viz[nod] = true;
  edges += A[nod].size() + 2 * l[nod];
  ans += 1LL * A[nod].size() * (A[nod].size() - 1) / 2;
  for (auto it : A[nod]) {
    if (!viz[it]) {
      dfs(it);
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      loops++;
      l[a]++;
    } else {
      A[a].push_back(b);
      A[b].push_back(a);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (A[i].size()) {
      dfs(i);
      break;
    }
  }
  if (edges / 2 != m) {
    cout << 0;
    return 0;
  }
  ans += (1LL * loops * (loops - 1) / 2) + 1LL * loops * (m - loops);
  cout << ans;
  return 0;
}
