#include <bits/stdc++.h>
using namespace std;
long long fix[2000005], n, m, a, b, w, ans, w1, x, mp[2000005];
vector<long long> v[2000005];
void dfs(long long a) {
  if (fix[a]) return;
  fix[a] = 1;
  for (long long i = 0; i < v[a].size(); i++) {
    if (!fix[v[a][i]]) dfs(v[a][i]);
  }
}
int main() {
  std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> a >> b;
    mp[a] = 1;
    mp[b] = 1;
    if (a == b) {
      w++;
    } else {
      v[a].push_back(b);
      v[b].push_back(a);
    }
    w1 = a;
  }
  dfs(w1);
  for (long long i = 1; i <= n; i++) {
    if (!fix[i] && mp[i]) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (long long i = 1; i <= n; i++) {
    x = v[i].size();
    ans += ((x * (x - 1) / 2));
  }
  cout << ans + (w * (m - 1)) - ((w * (w - 1)) / 2) << endl;
}
