#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> visited;
vector<int> plus_loop;
void is_connected(int u) {
  visited[u] = 1;
  for (int v : g[u]) {
    if (!visited[v]) is_connected(v);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  g = vector<vector<int> >(n);
  plus_loop = vector<int>(n, 0);
  long long num_loops = 0;
  int all_e = m;
  for (int i = 0, u, v; i < m; ++i) {
    cin >> u >> v;
    --u;
    --v;
    if (u == v) {
      ++plus_loop[v];
      ++num_loops;
      --all_e;
    } else {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  visited = vector<int>(n, 0);
  for (int i = 0; i < n; ++i) {
    if (g[i].size() > 0 || plus_loop[i]) {
      is_connected(i);
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (visited[i] == 0 && (g[i].size() > 0 || plus_loop[i])) {
      cout << 0;
      return 0;
    }
  }
  if (n == 1 || m < 2) {
    cout << 0;
    return 0;
  }
  long long sol = 0;
  for (int i = 0; i < n; ++i) {
    long long my_deg = g[i].size();
    if (my_deg >= 2LL) sol += (my_deg * (my_deg - 1LL)) / 2LL;
  }
  if (num_loops >= 2) sol += (num_loops * (num_loops - 1LL)) / 2LL;
  sol += all_e * num_loops;
  cout << sol;
}
