#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
vector<int> graph[MAXN];
bool mrk[MAXN];
bool has_loop[MAXN];
long long degree[MAXN];
int n;
void dfs(int v) {
  mrk[v] = true;
  int size = graph[v].size();
  for (int i = 0; i < size; i++) {
    int w = graph[v][i];
    if (!mrk[w]) {
      dfs(w);
    }
  }
}
bool is_connected() {
  for (int i = 1; i <= n; i++) {
    if (degree[i] > 0 || has_loop[i]) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!mrk[i] && (degree[i] > 0 || has_loop[i])) {
      return false;
    }
  }
  return true;
}
int main() {
  int m, a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    if (a == b) {
      has_loop[a] = true;
    } else {
      degree[a]++;
      degree[b]++;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
  }
  if (!is_connected() || m < 2) {
    printf("0\n");
    return 0;
  }
  long long answer = 0LL;
  for (int i = 1; i <= n; i++) {
    answer += (degree[i] * (degree[i] - 1LL)) / 2LL;
  }
  long long loop_count = 0LL;
  for (int i = 1; i <= n; i++) {
    if (has_loop[i]) {
      loop_count++;
    }
  }
  answer += (loop_count * (m - loop_count));
  answer += (loop_count * (loop_count - 1LL)) / 2LL;
  printf("%I64d\n", answer);
  return 0;
}
