#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G(1000011);
int n, nn, m, u[1000011], v[1000011], deg[1000011], loopCnt, cnt;
bool vis[1000011], hasEdge[1000011];
void dfs(int v) {
  vis[v] = 1;
  cnt++;
  for (auto x : G[v])
    if (!vis[x]) dfs(x);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u[i], &v[i]);
    if (!hasEdge[u[i]]) nn++;
    hasEdge[u[i]] = 1;
    if (!hasEdge[v[i]]) nn++;
    hasEdge[v[i]] = 1;
    G[u[i]].push_back(v[i]);
    G[v[i]].push_back(u[i]);
    if (u[i] == v[i])
      loopCnt++;
    else
      deg[u[i]]++, deg[v[i]]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (hasEdge[i]) {
      dfs(i);
      break;
    }
  }
  if (cnt != nn)
    cout << 0;
  else {
    long long ans = 0;
    for (int i = 0; i < m; ++i) {
      if (u[i] == v[i])
        ans += m - 1;
      else
        ans += (deg[u[i]] - 1) + (deg[v[i]] - 1) + loopCnt;
    }
    cout << ans / 2;
  }
  return 0;
}
