#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MN = 1e6 + 10;
int n, m;
vector<int> adj[MN];
bool mk[MN], is[MN];
int cmp_sz = 0;
void dfs(int s) {
  mk[s] = true;
  for (auto v : adj[s]) {
    if (!mk[v]) dfs(v);
    ++cmp_sz;
  }
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    if (a != b)
      adj[a].push_back(b), adj[b].push_back(a);
    else
      is[a] = true;
  }
  for (int i = 0; i < n; ++i) {
    if (is[i] || !adj[i].empty()) {
      dfs(i);
      break;
    }
  }
  for (int i = 0; i < n; ++i)
    if (!mk[i] && (!adj[i].empty() || is[i])) return printf("0\n"), 0;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int t = ((int)(adj[i]).size());
    ans += 1ll * t * (t - 1) / 2;
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) cnt += is[i];
  ans += 1ll * cnt * (m - cnt);
  ans += 1ll * cnt * (cnt - 1) / 2;
  printf("%I64d\n", ans);
  return 0;
}
