#include <bits/stdc++.h>
using namespace std;
typedef struct data {
  bool col;
  long long r;
  long long b;
} data;
vector<int> E[1000005];
int C[1000005];
int Self[1000005];
void dfs(int x) {
  C[x] = 1;
  for (int i = 0; i < E[x].size(); i++) {
    if (C[E[x][i]] == 0) dfs(E[x][i]);
  }
}
long long choose(long long N) {
  if (N < 2) return 0;
  long long R = ((N * (N - 1)) / 2);
  return R;
}
int main() {
  long long R = 0, N = 0, M = 0, i = 0, u = 0, v = 0, flag = 0, S = 0;
  memset(C, 0, sizeof(C));
  memset(Self, 0, sizeof(Self));
  scanf("%lld%lld", &N, &M);
  for (i = 0; i < M; i++) {
    scanf("%lld%lld", &u, &v);
    if (u != v) {
      E[u].push_back(v);
      E[v].push_back(u);
    } else {
      Self[u] = 1;
      S++;
    }
  }
  for (i = 1; i <= N; i++) {
    if (E[i].size() > 0 || Self[i] > 0) {
      dfs(i);
      break;
    }
  }
  for (i = 1; i <= N; i++) {
    if (C[i] == 0 && (E[i].size() > 0 || Self[i] > 0)) flag = 1;
  }
  if (flag == 1)
    R = 0;
  else {
    R = choose(S);
    R = R + (S * (M - S));
    for (i = 1; i <= N; i++) {
      R = R + choose(E[i].size());
    }
  }
  printf("%lld\n", R);
  return 0;
}
