#include <bits/stdc++.h>
using namespace std;
int f[1000005], v[1000005], z;
long long d[1000005], sf, c, ans;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  if (m < 2) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    z = x;
    f[find(x)] = find(y);
    v[x] = 1;
    v[y] = 1;
    if (x == y)
      sf++;
    else {
      d[x]++;
      d[y]++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (v[i] && find(i) != find(z)) {
      cout << 0;
      return 0;
    }
  ans = sf * (sf - 1) / 2 + sf * (m - sf);
  for (int i = 1; i <= n; i++) ans += d[i] * (d[i] - 1) / 2;
  cout << ans;
}
