#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int vis[N] = {};
vector<int> v[N];
void dfs(int source) {
  vis[source] = 1;
  for (int i = 0; i < v[source].size(); i++) {
    if (vis[v[source][i]] == 0) {
      dfs(v[source][i]);
    }
  }
  return;
}
long long c2(long long n) { return ((n * (n - 1)) / 2); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, x, y;
  long long e[N] = {};
  int self = 0, non_self = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (x == y) {
      self++;
      v[x].push_back(y);
    } else {
      e[x]++;
      e[y]++;
      non_self++;
      v[x].push_back(y);
      v[y].push_back(x);
    }
  }
  int cmp = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && v[i].size() > 0) {
      dfs(i);
      cmp++;
    }
  }
  if (cmp > 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = c2(self);
  ans = ans + (self * (long long)non_self);
  for (int i = 1; i <= n; i++) {
    if (e[i] > 0) {
      ans = ans + c2(e[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
