#include <bits/stdc++.h>
const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 50;
const int mod = 9901;
using namespace std;
int n, m;
vector<int> G[maxn];
int deg[maxn];
int loop;
bool vis[maxn];
bool ot[maxn];
bool bfs() {
  memset(vis, 0, sizeof(vis));
  queue<int> qu;
  int tot = 0, tar = 0;
  for (int i = 1; i <= n; i++) {
    if (ot[i]) {
      qu.push(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++)
    if (ot[i]) tar++;
  while (!qu.empty()) {
    int tp = qu.front();
    qu.pop();
    if (vis[tp]) continue;
    vis[tp] = 1;
    tot++;
    for (int v : G[tp]) {
      if (!vis[v]) qu.push(v);
    }
  }
  return tot == tar;
}
int main() {
  while (~scanf("%d %d", &n, &m)) {
    for (int i = 1; i < n + 1; i++) G[i].clear();
    memset(deg, 0, sizeof(deg));
    loop = 0;
    memset(ot, 0, sizeof(ot));
    for (int i = 0; i < m; i++) {
      int u, v;
      scanf("%d %d", &u, &v);
      if (u != v) {
        G[u].push_back(v);
        G[v].push_back(u);
        deg[u]++;
        deg[v]++;
      } else
        loop++;
      ot[u] = ot[v] = true;
    }
    if (!bfs()) {
      printf("0\n");
      continue;
    }
    long long ans = 0;
    for (int i = 1; i < n + 1; i++) {
      ans += (long long)(deg[i] - 1) * deg[i] / 2;
    }
    ans += (long long)loop * (m - 1);
    ans -= (long long)(loop - 1) * loop / 2;
    cout << ans << endl;
  }
  return 0;
}
