#include <bits/stdc++.h>
using namespace std;
long long ans;
long long self, n, m, u, v;
vector<long long> a[1000069];
bool kt[1000069], vi[1000069];
void DFS(long long u) {
  vi[u] = 1;
  for (long long i = 0; i < a[u].size(); i++) {
    v = a[u][i];
    if (!vi[v]) DFS(v);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    kt[u] = kt[v] = 1;
    if (u != v) {
      a[u].push_back(v);
      a[v].push_back(u);
    }
    if (u == v) self++;
  }
  for (long long i = 1; i <= n; i++) {
    if (kt[i]) {
      if (!vi[i]) {
        DFS(i);
        break;
      }
    }
  }
  ans = (long long)self * (m - self) + (long long)self * (self - 1) / 2;
  for (long long i = 1; i <= n; i++) {
    if (!vi[i] && kt[i]) {
      cout << 0;
      return 0;
    }
    ans += (long long)a[i].size() * (a[i].size() - 1) / 2;
  }
  cout << ans;
}
