#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return !b ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T sqr(T a) {
  return a * a;
}
template <typename T>
T cube(T a) {
  return a * a * a;
}
template <typename T>
inline void smin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void smax(T &a, T b) {
  a = a > b ? a : b;
}
int in() {
  int n;
  scanf("%d", &n);
  return n;
}
long long Lin() {
  long long n;
  scanf("%lld", &n);
  return n;
}
double Din() {
  double n;
  scanf("%lf", &n);
  return n;
}
const long long inf = (long long)1e17;
const long long mod = (long long)1e9 + 7;
const int N = 1e6 + 5;
vector<int> g[N];
int x[N], vis[N];
int dfs(int u) {
  vis[u] = 1;
  int ans = 1;
  for (auto v : g[u]) {
    if (!vis[v]) ans += dfs(v);
  }
  return ans;
}
int solve() {
  int n = in(), m = in(), loop = 0;
  for (int i = 1; i <= m; i++) {
    int u = in(), v = in();
    x[u] = 1, x[v] = 1;
    if (u == v)
      loop++;
    else {
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  bool ok = true;
  int comp = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i]) comp++;
    if (ok && x[i]) ok = false, comp -= dfs(i);
  }
  if (comp) return printf("0\n");
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long d = (long long)g[i].size();
    ans += (d * (d - 1)) / 2;
  }
  ans += ((long long)loop * (loop - 1)) / 2;
  ans += (long long)loop * ((long long)m - (long long)loop);
  cout << ans << '\n';
  return 0;
}
int main() {
  int test = 1, tc = 0;
  while (test--) {
    solve();
  }
  return 0;
}
