#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int M = 1e6 + 5;
int n, m;
vector<int> g[M];
bool us[M], was[M];
void dfs(int v) {
  us[v] = 1;
  for (int i = 0; i < g[v].size(); ++i)
    if (!us[g[v][i]]) dfs(g[v][i]);
}
int main() {
  scanf("%d%d", &n, &m);
  int v, u;
  long long k = 0;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &v, &u);
    was[v] = was[u] = 1;
    if (v == u) {
      ++k;
      continue;
    }
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(v);
  for (int i = 1; i <= n; ++i)
    if (was[i] && !us[i]) cout << 0, exit(0);
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < g[i].size(); ++j) ans += g[g[i][j]].size() - 1;
  cout << ans / 2 - k * (k - 1) / 2 + k * (m - 1);
}
