#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmax(T& a, const T& b) {
  return a < b ? (a = b, true) : false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  return b < a ? (a = b, true) : false;
}
int N, M;
vector<pair<int, int> > edge[1000001];
bool used[1000001];
long long cnt[1000001];
bool dfs(int curr) {
  bool res = false;
  for (const auto& it : edge[curr]) {
    if (used[it.second] == false) {
      used[it.second] = true;
      dfs(it.first);
      res = true;
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &N, &M);
  long long x = 0;
  vector<int> t(N + 1);
  for (int i = (int)(0); i < (int)(M); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v) {
      edge[u].push_back({v, i});
      x++;
    } else {
      edge[u].push_back({v, i});
      edge[v].push_back({u, i});
      cnt[u]++;
      cnt[v]++;
    }
  }
  for (int i = (int)(1); i < (int)(N + 1); i++) {
    if (dfs(i)) break;
  }
  for (int i = (int)(0); i < (int)(M); i++) {
    if (used[i] == false) {
      printf("0\n");
      return 0;
    }
  }
  long long ans = x * (x - 1) / 2 + x * (M - x);
  for (int i = (int)(1); i < (int)(N + 1); i++)
    if (cnt[i] >= 2) {
      ans += cnt[i] * (cnt[i] - 1) / 2;
    }
  printf("%lld\n", ans);
  return 0;
}
