#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 4;
vector<int> v[N];
int visit[N], comp_size;
void dfs(int node) {
  visit[node] = 1;
  comp_size++;
  for (int it : v[node])
    if (!visit[it]) dfs(it);
}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  vector<int> deg(n + 1, 0), has_loops;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    if (a == b)
      deg[a]++, has_loops.push_back(a);
    else
      deg[a]++, deg[b]++;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  int components = 0;
  for (int i = 1; i < n + 1; i++)
    if (!visit[i]) {
      comp_size = 0;
      dfs(i);
      if (comp_size > 1 or v[i].size()) components++;
    }
  if (components > 1) {
    printf("%d", 0);
    return 0;
  }
  long long ans = 0;
  ans = 1LL * (int)has_loops.size() * (m - 1);
  long long temp = (long long)has_loops.size();
  temp *= (temp - 1);
  temp /= 2;
  ans -= temp;
  for (int i = 1; i < n + 1; i++) {
    long long here = deg[i];
    here *= (here - 1);
    here /= 2;
    ans += here;
  }
  for (int it : has_loops) {
    ans -= (deg[it] - 1);
  }
  printf("%lld", ans);
  return 0;
}
