#include <bits/stdc++.h>
using namespace std;
void hal() { exit(0); }
const int MAX_N = 1000333;
int n;
vector<int> a[MAX_N];
bool used[MAX_N];
bool mark[MAX_N];
int dfs(int v) {
  used[v] = true;
  int res = static_cast<int>(mark[v]);
  for (int u : a[v]) {
    if (!used[u]) {
      res += dfs(u);
    }
  }
  return res;
}
void solve() {
  int m;
  cin >> n >> m;
  long long bad = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    mark[x] = mark[y] = true;
    if (x != y) {
      a[x].push_back(y);
      a[y].push_back(x);
    } else {
      bad++;
    }
  }
  int cnt = 0;
  int v = 1;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) {
      cnt++;
      v = i;
    }
  }
  if (dfs(v) != cnt) {
    cout << "0\n";
    return;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += static_cast<long long>(a[i].size()) * (a[i].size() - 1) / 2;
  }
  ans += (m - bad) * bad + bad * (bad - 1) / 2;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  int tc;
  solve();
  return 0;
}
