#include <bits/stdc++.h>
using namespace std;
long long deg[1000010];
int visited[1000010];
int edge[1000100];
vector<long long> v[1000010];
void dfs(long long x) {
  if (visited[x]) return;
  visited[x] = 1;
  for (int i = 0; i < v[x].size(); i++) dfs(v[x][i]);
}
int main() {
  long long n, m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  long long loop = 0;
  long long root;
  long long mm = m;
  while (mm--) {
    long long a, b;
    scanf("%lld", &a);
    scanf("%lld", &b);
    edge[a] = 1;
    edge[b] = 1;
    root = a;
    if (a == b) {
      loop++;
      continue;
    }
    v[a].push_back(b);
    v[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  dfs(root);
  for (int i = 1; i <= n; i++) {
    if (edge[i] != visited[i]) {
      cout << "0\n";
      return 0;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += ((deg[i]) * (deg[i] - 1)) / 2;
  }
  ans += loop * (m - loop);
  ans += loop * (loop - 1) / 2;
  cout << ans << "\n";
  return 0;
}
