#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
const int MOD = 1e9 + 7;
const long long inf = 2e18;
int n, m;
long long ans = 0;
vector<int> g[maxn];
bool togh[maxn], vis[maxn];
void dfs(int v) {
  vis[v] = 1;
  for (auto i : g[v]) {
    if (!vis[i]) dfs(i);
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (u != v) {
      g[u].push_back(v);
      g[v].push_back(u);
    } else
      togh[u] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (togh[i] || g[i].size()) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && (togh[i] || g[i].size())) {
      cout << 0 << '\n';
      return;
    }
  }
  for (int i = 1; i <= n; i++) {
    long long x = g[i].size();
    ans += 1ll * x * (x - 1) / 2;
  }
  long long c = 0;
  for (int i = 1; i <= n; i++) c += togh[i];
  ans += 1ll * c * (c - 1) / 2;
  ans += 1ll * c * (m - c);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
