#include <bits/stdc++.h>
using namespace std;
int n, m;
int *dag;
int *f;
int scc = 0;
bool *haveedge;
int find(int x) { return (f[x] == x) ? (x) : (f[x] = find(f[x])); }
inline void init() {
  scanf("%d%d", &n, &m);
  dag = new int[(n + 1)];
  f = new int[(n + 1)];
  haveedge = new bool[(n + 1)];
  memset(dag, 0, sizeof(int) * (n + 1));
  for (int i = 1; i <= n; i++) f[i] = i, haveedge[i] = false;
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    dag[u] += u != v, dag[v] += u != v;
    haveedge[u] = haveedge[v] = true;
    scc += u == v;
    f[find(u)] = find(v);
  }
}
long long res = 0;
int cnt = 0;
inline void solve() {
  for (int i = 1; i <= n; i++) {
    res += (dag[i] * 1LL * (dag[i] - 1)) >> 1;
    cnt += f[i] == i && haveedge[i];
  }
  printf(
      "%lld"
      "\n",
      (cnt == 1)
          ? (res + (scc * 1LL * (m - 1)) - ((scc * 1LL * (scc - 1)) >> 1))
          : (0));
}
int main() {
  init();
  solve();
  return 0;
}
