#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
bool mark[maxn];
long long n, m, cnt, d[maxn], no, edge;
vector<long long> g[maxn];
void dfs(long long v = 1) {
  mark[v] = true;
  for (long long i = 0; i < g[v].size(); i++) {
    edge = 1;
    if (!mark[g[v][i]]) dfs(g[v][i]);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long cnt1 = 0, ans = 0;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    if (x == y)
      cnt1++;
    else {
      d[x]++;
      d[y]++;
    }
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++)
    if (!mark[i]) {
      dfs(i);
      if (edge) no++;
      edge = 0;
    }
  if (no > 1) {
    cout << 0;
    return 0;
  }
  for (long long i = 1; i <= n; i++) ans += (d[i] * (d[i] - 1)) / 2;
  ans += cnt1 * (m - cnt1);
  ans += (cnt1 * (cnt1 - 1)) / 2;
  cout << ans;
}
