#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
int f[N], deg[N];
bool self[N];
int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) f[i] = i;
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    int rx = find(x), ry = find(y);
    if (rx != ry) {
      f[ry] = rx;
    }
    deg[x]++;
    if (x != y) {
      deg[y]++;
    } else {
      self[x] = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (deg[i] && find(i) == i) ++cnt;
  }
  if (cnt > 1) {
    puts("0");
    return 0;
  }
  long long ret = 0, self_cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (self[i]) {
      ++self_cnt;
      ret += (long long)(deg[i] - 1) * (deg[i] - 2) / 2;
    } else {
      ret += (long long)deg[i] * (deg[i] - 1) / 2;
    }
  }
  ret += self_cnt * (m - 1);
  ret -= self_cnt * (self_cnt - 1) / 2;
  printf("%lld\n", ret);
  return 0;
}
