#include <bits/stdc++.h>
using namespace std;
struct st {
  long long idx, val;
};
vector<st> v[1000004];
int visited[1000004];
int visited2[1000004];
int ans[1000004];
long long a, b, cnt, p, chk;
void dfs(int idx2) {
  if (visited2[idx2] == 1) {
    chk++;
    visited2[idx2] = 2;
  }
  for (auto it : v[idx2]) {
    if (visited[it.idx]) continue;
    visited[it.idx] = 1;
    cnt++;
    dfs(it.val);
  }
}
long long combi(int k, int r) {
  if (r == 0 || k == r) return 1;
  if (r > k / 2) r = k - r;
  long long ret = 1;
  for (long long i = 1; i <= r; i++) {
    ret = ret * (k - i + 1) / i;
  }
  return ret;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%lld%lld", &a, &b);
    if (a == b) {
      visited2[a] = 1;
      p++;
      continue;
    }
    v[a].push_back({i, b});
    v[b].push_back({i, a});
  }
  for (int i = 1; i <= n; i++) {
    if (v[i].size()) {
      dfs(i);
      break;
    }
  }
  if (cnt != m - p || chk != p)
    printf("0");
  else {
    for (int i = 1; i <= n; i++) ans[v[i].size()]++;
    cnt = 0;
    for (int i = 2; i <= m; i++) {
      if (ans[i]) {
        cnt += ans[i] * combi(i, 2);
      }
    }
    cnt += p * (m - 1);
    if (p >= 2) cnt -= combi(p, 2);
    printf("%lld", cnt);
  }
}
