#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int>> e[1000010];
long long deg[1000010];
int visitede[1000010];
int cnt;
long long scnt;
void dfs(int x) {
  for (auto next : e[x]) {
    if (!visitede[next.second]) {
      visitede[next.second] = true;
      cnt++;
      dfs(next.first);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int head = -1;
  for (int i = 0; i < m; i++) {
    int f, t;
    scanf("%d%d", &f, &t);
    f--;
    t--;
    head = f;
    if (f != t) {
      e[f].push_back({t, i});
      e[t].push_back({f, i});
      deg[f]++;
      deg[t]++;
    } else {
      e[f].push_back({f, i});
      scnt++;
    }
  }
  dfs(head);
  if (cnt == m) {
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      ans += deg[i] * (deg[i] - 1) / 2;
    }
    ans += scnt * (m - 1);
    ans -= (scnt) * (scnt - 1) / 2;
    printf("%lld\n", ans);
  } else
    printf("0\n");
}
