#include <bits/stdc++.h>
using namespace std;
void dfs(const vector<vector<int> >& edge_list, vector<bool>& visited, int i,
         int& edges) {
  visited[i] = true;
  for (int j : edge_list[i]) {
    if (!visited[j]) dfs(edge_list, visited, j, edges);
    if (j >= i) ++edges;
  }
}
int main() {
  int n, m, u, v;
  scanf("%d %d", &n, &m);
  vector<int> deg_noloop(n, 0);
  vector<vector<int> > edge_list(n);
  vector<bool> visited(n, false);
  long long nonloops = 0, loops = 0, good_paths = 0;
  int start = 0, edges = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    --u;
    --v;
    start = u;
    if (u != v) {
      edge_list[u].push_back(v);
      edge_list[v].push_back(u);
      ++deg_noloop[u];
      ++deg_noloop[v];
      ++nonloops;
    } else {
      edge_list[u].push_back(v);
      ++loops;
    }
  }
  dfs(edge_list, visited, start, edges);
  for (int i = 0; i < n; i++) {
    long long deg = deg_noloop[i];
    if (deg >= 2) good_paths += (deg) * (deg - 1) / 2;
  }
  good_paths += loops * nonloops + (loops) * (loops - 1) / 2;
  if (edges < m) good_paths = 0;
  printf("%lld\n", good_paths);
}
