#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 5;
vector<int> g[MAXN];
int n, m;
long long cnt;
bool have_edge[MAXN];
bool used[MAXN];
void dfs(int v) {
  if (used[v]) return;
  used[v] = 1;
  for (int i = 0; i < (int)g[v].size(); i++) dfs(g[v][i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    have_edge[a] = 1;
    have_edge[b] = 1;
    if (a == b)
      cnt++;
    else {
      g[a].push_back(b);
      g[b].push_back(a);
    }
  }
  int v = 0;
  while (!have_edge[v] && v != n) v++;
  assert(v != n);
  dfs(v);
  for (int i = 0; i < n; i++)
    if (have_edge[i] && !used[i]) {
      cout << 0 << '\n';
      return 0;
    }
  long long res = cnt * (cnt - 1) / 2 + cnt * (m - cnt);
  for (int i = 0; i < n; i++)
    res += (long long)g[i].size() * (g[i].size() - 1) / 2;
  cout << res << '\n';
  return 0;
}
