#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int n, m;
vector<int> V[1110005];
bool flag[1110005];
long long x = 0, tep = 0;
void dfs(int par, int u) {
  flag[u] = 1;
  for (int i = 0; i < (((long long)(V[u]).size())); ++i) {
    int v = V[u][i];
    tep++;
    if (!flag[v]) dfs(u, v);
  }
}
void solve() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    int u, v;
    cin >> u >> v;
    V[u].push_back(v);
    V[v].push_back(u);
    if (u == v) {
      x++;
    }
  }
  memset(flag, 0, sizeof(flag));
  for (int i = 1; i <= n; i++)
    if (((long long)(V[i]).size())) {
      dfs(0, i);
      break;
    }
  if (tep == m + m) {
    long long res = 0;
    res = x * (x - 1) / 2 + x * (m - x);
    for (int i = (1); i <= (n); ++i) {
      long long T = 0;
      for (int j = 0; j < (((long long)(V[i]).size())); ++j) {
        int u = V[i][j];
        if (u != i) T++;
      }
      res += T * (T - 1) / 2;
    }
    cout << res << endl;
  } else
    cout << 0;
}
int main() {
  solve();
  return 0;
}
