#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
ll m;
vector<int> g[1000100];
int cnt[1000010];
ll dgree[1000010];
int vis[1000010];
ll loop;
ll ans;
int flag;
int in[1000010];
queue<int> q;
int dfs(int k) {
  vis[k] = 1;
  for (int i = 0; i < g[k].size(); i++) {
    int u = g[k][i];
    if (!vis[u]) dfs(u);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    if (x == y) {
      if (!in[x]) {
        q.push(x);
        in[x] = 1;
      }
      loop++;
      continue;
    }
    dgree[x]++;
    dgree[y]++;
    flag = 1;
    g[x].push_back(y);
    g[y].push_back(x);
    if (!in[x]) {
      q.push(x);
      in[x] = 1;
    }
    if (!in[y]) {
      q.push(y);
      in[y] = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    if (dgree[i] && !vis[i]) {
      dfs(i);
      break;
    }
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (!vis[x]) return 0 * puts("0");
  }
  for (int i = 1; i <= n; i++) {
    ans += dgree[i] * (dgree[i] - 1) / 2;
  }
  if (flag) {
    if (loop) ans += loop * (m - 1);
    if (loop) ans -= loop * (loop - 1) / 2;
  }
  cout << ans;
}
