#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int nn = 1000002;
vector<int> adj[nn];
int seen[nn];
int d[nn];
void dfs(int x) {
  seen[x] = 1;
  for (int y : adj[x])
    if (!seen[y]) dfs(y);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int o = 0, e = 0;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == y)
      ++o, ++d[x];
    else {
      adj[x].push_back(y);
      adj[y].push_back(x);
      ++e;
    }
  }
  for (int x = 1; x <= n; ++x)
    if (adj[x].size()) {
      dfs(x);
      break;
    }
  long long ret = 0;
  if (e) {
    for (int i = 1; i <= n; ++i)
      if (!seen[i] && (adj[i].size() || d[i])) {
        printf("%I64d\n", ret);
        return 0;
      }
    ret += (o + 0ll) * e + ((o + 0ll) * (o - 1)) / 2;
    for (int x = 1; x <= n; ++x)
      ret += ((adj[x].size() + 0ll) * (adj[x].size() + 0ll - 1)) / 2;
  }
  printf("%I64d\n", ret);
  return 0;
}
