#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n, m;
vector<int> V[N], G[N];
int vis[N], cnt, edge;
int self, u, v;
void dfs(int cur) {
  vis[cur] = 1;
  cnt++;
  edge += V[cur].size();
  for (int i = 0; i < V[cur].size(); i++) {
    int u = V[cur][i];
    if (vis[u]) continue;
    dfs(u);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    V[u].push_back(v);
    V[v].push_back(u);
    if (u == v) self++;
    if (u == v) continue;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    edge = 0;
    cnt = 0;
    if (vis[i]) continue;
    dfs(i);
    if (edge && edge / 2 < m) {
      cout << 0 << endl;
      return 0;
    }
  }
  long long ans = 0;
  ans += 1ll * self * (self - 1) / 2;
  ans += 1ll * self * (m - self);
  for (int i = 1; i <= n; i++) {
    int sz = G[i].size();
    ans += 1ll * sz * (sz - 1) / 2;
  }
  cout << ans << endl;
}
