#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, u, v, root, vis[1000005], f[1000005], edg[1000005];
long long ans;
vector<int> G[1000005];
void dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    edg[u] = edg[v] = true;
    if (u == v) {
      cnt++;
      continue;
    }
    G[u].push_back(v);
    G[v].push_back(u);
    f[u]++, f[v]++;
    root = u;
  }
  dfs(u);
  bool flag = true;
  for (int i = 1; i <= n; i++)
    if (edg[i]) flag &= vis[i];
  for (int i = 1; i <= n; i++) ans += 1ll * f[i] * (f[i] - 1) / 2;
  cout << flag * (ans + 1ll * cnt * (m - cnt) + 1ll * cnt * (cnt - 1) / 2)
       << endl;
}
