#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, vk = 0, vv = 0;
long long res = 0, se = 0;
int visited[1000000], selfE[1000000];
vector<vector<int> > G(1000000, vector<int>());
void dfs(int i) {
  if (visited[i]) return;
  visited[i] = 1;
  vk++;
  for (int u : G[i]) {
    dfs(u);
  }
}
void solve() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    if (u == v) {
      selfE[v - 1] += 1;
      se++;
    } else {
      G[u - 1].push_back(v - 1);
      G[v - 1].push_back(u - 1);
    }
  }
  for (int i = 0; i < n; i++) {
    long long l = G[i].size();
    res += l * (l - 1) / 2;
  }
  res += se * (se - 1) / 2;
  res += se * (m - se);
  memset(visited, 0, sizeof visited);
  for (int i = 0; i < n; i++) {
    if (G[i].size()) {
      dfs(i);
      break;
    }
  }
  for (int i = 0; i < n; i++)
    if (G[i].size() || selfE[i]) vv++;
  if (vk == vv)
    cout << res << endl;
  else
    cout << 0 << endl;
}
int main() {
  solve();
  return 0;
}
