#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> ke[1000010];
bool cx[1000010], visited[1000010];
void dfs(int u) {
  visited[u] = true;
  for (int v : ke[u])
    if (!visited[v]) dfs(v);
}
long long c2(int x) { return (1LL * x * (x - 1)) >> 1; }
int main() {
  if (fopen("a.txt", "r")) {
    freopen("a.txt", "r", stdin);
  } else
    ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  int own = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    cx[u] = true;
    cx[v] = true;
    if (u != v) {
      ke[u].push_back(v);
      ke[v].push_back(u);
    } else
      own++;
  }
  int cnt = 0;
  for (int u = 1; u <= n; u++)
    if (cx[u] && !visited[u]) {
      dfs(u);
      cnt++;
    }
  if (cnt != 1) {
    cout << 0;
    exit(0);
  };
  long long res = 0;
  for (int i = 1; i <= n; i++) res += c2(int(ke[i].size()));
  res += c2(own);
  res += 1LL * own * (m - own);
  cout << res;
}
