#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
vector<int> adj[N];
int u[N];
int v[N];
int deg[N];
bool vis[N];
int cnt = 0;
void dfs(int u) {
  cnt++;
  vis[u] = 1;
  for (auto v : adj[u])
    if (!vis[v]) dfs(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, all = 0;
  long long ans = 0, loops = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (u == v)
      loops++;
    else {
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    if (!vis[u]) all++;
    if (!vis[v]) all++;
    if (u == v && !vis[u]) all--;
    vis[u] = vis[v] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (vis[i]) {
      memset(vis, 0, sizeof vis);
      dfs(i);
      break;
    }
  if (cnt != all) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    long long x = adj[i].size();
    ans += x * (x - 1) / 2;
  }
  ans += loops * (loops - 1) / 2 + loops * (m - loops);
  cout << ans << endl;
  return 0;
}
