#include <bits/stdc++.h>
using namespace std;
long long int fastpow(long long int tab, long long int us) {
  if (tab == 0) return 0;
  if (tab == 1) return 1;
  if (us == 0) return 1;
  if (us == 1) return tab % 1000000007;
  tab %= 1000000007;
  if (us % 2 == 1) return tab * fastpow(tab, us - 1) % 1000000007;
  long long int a = fastpow(tab, us / 2) % 1000000007;
  return a * a % 1000000007;
}
long long int n, bidi = 0, m, t = 1;
vector<bool> vis, exi;
vector<vector<long long int> > graph;
void dfs(long long int a) {
  long long int i;
  if (vis[a]) return;
  vis[a] = 1;
  for (i = 0; i < graph[a].size(); i++) dfs(graph[a][i]);
  return;
}
void solve() {
  long long int a, b, i, j, k, cev = 0;
  cin >> n >> m;
  vis.resize(n + 5);
  exi.resize(n + 5);
  graph.resize(n + 5);
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    if (a == b)
      bidi++;
    else {
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    exi[a] = 1;
    exi[b] = 1;
  }
  i = 1;
  while (exi[i] == 0) i++;
  dfs(i);
  for (i = 1; i <= n; i++) {
    if (vis[i] != exi[i]) {
      cout << 0 << endl;
      return;
    }
  }
  for (i = 1; i <= n; i++) {
    cev += (((long long int)graph[i].size()) *
            ((long long int)graph[i].size() - 1)) /
           2;
  }
  if (bidi > 0) {
    cev += bidi * (m - bidi);
    cev += (bidi * (bidi - 1)) / 2;
  }
  cout << cev << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  while (t--) solve();
  return 0;
}
