#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
int parent[N];
int mark[N];
long long degree[N];
int findparent(int v) {
  if (v != parent[v]) {
    parent[v] = findparent(parent[v]);
  }
  return parent[v];
}
void dsu(int u, int v) { parent[findparent(v)] = findparent(u); }
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  if (m < 2) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
  }
  long long self = 0, use = -1;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    mark[u] = mark[v] = 1;
    dsu(u, v);
    if (u == v) {
      self++;
    } else {
      degree[u]++;
      degree[v]++;
    }
    use = u;
  }
  for (int i = 1; i <= n; i++) {
    if (mark[i] && findparent(i) != findparent(use)) {
      puts("0");
      return 0;
    }
  }
  long long ans = (self * (self - 1)) / 2 + self * (m - self);
  for (int i = 1; i <= n; i++) {
    ans += (degree[i] * (degree[i] - 1) / 2);
  }
  cout << ans << endl;
  return 0;
}
