#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int A[maxn + 1], n, m, k, root[maxn + 1];
long long ans;
bool Free[maxn + 1];
int Get(int u) {
  if (!root[u])
    return u;
  else
    return root[u] = Get(root[u]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (u == v)
      k++;
    else {
      A[u]++;
      A[v]++;
      u = Get(u);
      v = Get(v);
      if (u != v) root[v] = u;
    }
    Free[u] = Free[v] = 1;
  }
  int ROOT = 0;
  for (int i = 1; i <= n; i++)
    if (Free[i]) ROOT = Get(i);
  for (int i = 1; i <= n; i++)
    if (Free[i] && Get(i) != ROOT) {
      cout << "0";
      return 0;
    }
  if (k > 0) ans += 1ll * k * (m - k) + 1ll * k * (k - 1) / 2;
  for (int i = 1; i <= n; i++) ans += 1LL * A[i] * (A[i] - 1) / 2;
  cout << ans;
  return 0;
}
