#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v;
} e[1000005];
vector<int> g[1000005];
static int du[1000005], loop;
int n, m, vis[1000005];
long long ans = 0;
void dfs(int p) {
  vis[p] = 1;
  for (int i = 0; i < g[p].size(); i++)
    if (!vis[g[p][i]]) dfs(g[p][i]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &e[i].u, &e[i].v);
    if (e[i].u != e[i].v) {
      g[e[i].u].push_back(e[i].v);
      g[e[i].v].push_back(e[i].u);
    } else
      loop++;
    du[e[i].u]++;
    du[e[i].v]++;
  }
  for (int i = 2; i <= n; i++)
    if (du[i]) {
      dfs(i);
      break;
    }
  for (int i = 1; i <= n; i++)
    if (du[i] && !vis[i]) {
      printf("0");
      return 0;
    }
  for (int i = 1; i <= m; i++)
    if (e[i].u != e[i].v) {
      ans += loop;
      ans += g[e[i].u].size() - 1 + g[e[i].v].size() - 1;
    } else
      ans += m - 1;
  printf("%I64d", ans / 2);
  return 0;
}
