#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, m;
long long self[N], deg[N];
vector<vector<int> > g;
bool seen[N];
void dfs(int v) {
  seen[v] = true;
  for (auto x : g[v])
    if (!seen[x]) dfs(x);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  g = vector<vector<int> >(n + 1, vector<int>());
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    if (a == b) {
      self[a]++;
    }
    deg[a]++;
    deg[b]++;
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] > 0) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!seen[i] && deg[i] > 0) {
      cout << "0\n";
      return 0;
    }
  }
  long long ret = 0, tot_self = 0;
  for (int i = 1; i <= n; i++) {
    tot_self += self[i];
  }
  ret += tot_self * (tot_self - 1) / 2 + tot_self * (m - tot_self);
  for (int i = 1; i <= n; i++) {
    ret += (deg[i] - 2 * self[i]) * (deg[i] - 2 * self[i] - 1) / 2;
  }
  cout << ret << "\n";
  return 0;
}
