#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = int(1e6) + 10;
int n, m, deg[N], U[N], V[N], cnt = 0, loop;
vector<int> g[N];
bool vis[N];
int adj(int u, int e) { return U[e] == u ? V[e] : U[e]; }
void dfs(int u) {
  for (auto e : g[u]) {
    if (!vis[e]) {
      cnt++;
      vis[e] = true;
      dfs(adj(u, e));
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  int root = 0;
  for (int i = (int)0; i < (int)m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    U[i] = u;
    V[i] = v;
    root = u;
    g[u].push_back(i);
    g[v].push_back(i);
    if (u != v) {
      deg[u]++;
      deg[v]++;
    } else {
      loop++;
    }
  }
  dfs(root);
  __f("cnt, m", cnt, m);
  if (cnt != m) {
    cout << 0 << endl;
    return 0;
  }
  long long int ans =
      ((1LL * loop) * (1LL * loop - 1)) / 2 + 1LL * loop * (1LL * m - loop);
  for (int i = (int)0; i < (int)n; i++) {
    ans += ((1LL * deg[i]) * (1LL * deg[i] - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
