#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
long long ans = 0;
bool vis[MAXN], possible = true;
int N, M, loop[MAXN];
long long loops = 0, e = 0;
vector<int> G[MAXN];
void dfs(int v) {
  vis[v] = true;
  for (int i = 0; i < (int)G[v].size(); i++) {
    int u = G[v][i];
    if (!vis[u]) dfs(u);
  }
}
int main() {
  scanf("%d", &N), scanf("%d", &M);
  for (int i = 0; i < (int)M; i++) {
    int v, u;
    scanf("%d", &v), scanf("%d", &u);
    v--, u--;
    if (v == u) {
      loops++;
      loop[v]++;
    } else {
      G[v].push_back(u);
      G[u].push_back(v);
      e++;
    }
  }
  for (int v = 0; v < (int)N; v++)
    if (G[v].size() > 0 || loop[v] > 0) {
      dfs(v);
      for (int u = 0; u < (int)N; u++)
        if ((G[u].size() > 0 || loop[u] > 0) && !vis[u]) possible = false;
      break;
    }
  if (!possible)
    printf("0\n");
  else {
    ans = loops * e + loops * (loops - 1) / 2;
    for (int v = 0; v < (int)N; v++) {
      long long sz = G[v].size();
      ans += sz * (sz - 1) / 2;
    }
    printf("%lld\n", ans);
  }
}
