#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
vector<int> g[maxn];
int visit[maxn];
vector<pair<int, int> > v;
long long int c2(long long int x) {
  if (x % 2 == 0) {
    return (x - 1) * (x / 2);
  }
  return x * ((x - 1) / 2);
}
void dfs(int node) {
  visit[node] = 1;
  for (int i = 0; i <= (int)g[node].size() - 1; i++) {
    if (visit[g[node][i]]) continue;
    dfs(g[node][i]);
  }
}
void solve() {
  int n, p, m, k = 0, z = 0, y, x;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    v.push_back(make_pair(x, y));
    if (x == y)
      k++;
    else {
      g[x].push_back(y);
      g[y].push_back(x);
      z++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if ((int)g[i].size() > 0) {
      dfs(i);
      break;
    }
  }
  x = 0;
  for (int i = 0; i <= (int)v.size() - 1; i++) {
    if (!visit[v[i].first] and !visit[v[i].second]) {
      x = 1;
      break;
    }
  }
  if (x == 1) {
    puts("0");
    return;
  }
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (1ll * c2((long long)(int)g[i].size()));
  }
  ans += c2((long long)k);
  ans += (1ll * k * z);
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
