#include <bits/stdc++.h>
using namespace std;
int n, A[1000001], m, loop;
vector<int> P[1000001];
queue<int> Q;
bool flag[1000001], flag_begin[1000001];
long long res;
bool ck() {
  for (int i = 1; i <= n; i++) flag[i] = true;
  for (int i = 1; i <= n; i++)
    if (flag_begin[i]) {
      flag[i] = false;
      Q.push(i);
      break;
    }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (P[u].empty()) continue;
    for (int i = 0; i <= P[u].size() - 1; i++)
      if (flag[P[u][i]]) {
        flag[P[u][i]] = false;
        Q.push(P[u][i]);
      }
  }
  for (int i = 1; i <= n; i++)
    if (flag[i] && flag_begin[i]) return false;
  return true;
}
int main() {
  res = loop = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) A[i] = 0;
  for (int i = 1; i <= n; i++) flag_begin[i] = false;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v)
      loop++;
    else {
      P[u].push_back(v);
      P[v].push_back(u);
      A[u]++;
      A[v]++;
    }
    flag_begin[u] = flag_begin[v] = true;
  }
  if (!ck()) {
    printf("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) res += ((1LL * A[i] * (A[i] - 1)) / 2LL);
  res += (1LL * loop * (m - 1));
  res -= ((1LL * loop * (loop - 1)) / 2LL);
  printf("%lld", res);
  return 0;
}
