#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int mod = 10007;
const double PI = acos(-1.0);
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
vector<int> e[1110007];
int vis[1110007];
int deg[1110007];
void dfs(int u) {
  vis[u] = 1;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long cnt = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    deg[u]++;
    deg[v]++;
    if (u != v) {
      e[u].push_back(v);
      e[v].push_back(u);
    } else
      cnt++;
  }
  for (int i = 1; i <= n; i++) {
    if (e[i].size()) {
      dfs(i);
      break;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0 && deg[i]) {
      puts("0");
      return 0;
    }
  }
  for (int i = 0; i <= n; i++) {
    ans += 1ll * e[i].size() * (e[i].size() - 1) / 2;
  }
  ans = ans + cnt * (m - 1) - cnt * (cnt - 1) / 2;
  printf("%I64d\n", ans);
}
