#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
bool vis[maxn];
int mk[maxn];
vector<int> G[maxn];
void dfs(int u) {
  vis[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  int n, m, loop, num;
  int u, v;
  scanf("%d%d", &n, &m);
  loop = 0;
  num = 0;
  memset(vis, 0, sizeof(vis));
  memset(mk, 0, sizeof(mk));
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    if (u != v) {
      G[u].push_back(v);
      G[v].push_back(u);
    } else {
      loop++;
      mk[u] = 1;
      G[u].push_back(v);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (G[i].size()) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (G[i].size() && !vis[i]) {
      printf("0\n");
      return 0;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int t = G[i].size();
    if (t) {
      if (mk[i]) t--;
      ans += (long long)t * (t - 1) / 2;
    }
  }
  ans += (long long)loop * (m - loop);
  ans += (long long)loop * (loop - 1) / 2;
  printf("%I64d\n", ans);
  return 0;
}
