#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
long long loops;
int N, M;
vector<int> G[MAXN];
bool vis[MAXN], matter[MAXN];
void dfs(int v) {
  vis[v] = 1;
  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);
    u--;
    v--;
    if (u == v)
      loops++;
    else {
      G[v].push_back(u);
      G[u].push_back(v);
    }
    matter[u] = matter[v] = true;
  }
  for (int i = 0; i < (int)N; i++) {
    if (matter[i]) {
      dfs(i);
      break;
    }
  }
  bool good = true;
  for (int v = 0; v < (int)N; v++)
    if (!vis[v] && matter[v]) good = false;
  if (!good) {
    printf("0\n");
    return 0;
  }
  long long ans = 0;
  for (int v = 0; v < (int)N; v++) {
    long long deg = G[v].size();
    ans += deg * (deg - 1) / 2;
  }
  ans += loops * (M - loops);
  ans += loops * (loops - 1) / 2;
  printf("%lld\n", ans);
}
