#include <bits/stdc++.h>
using namespace std;
int n, m;
long long rez;
int comp[1000009];
int d[1000009];
bool vis[1000009];
int c(int i) {
  if (comp[i] == i) return i;
  comp[i] = c(comp[i]);
  return comp[i];
}
int loops;
inline int mna(int a, int b) { return (a < b ? a : b); }
void readFile() {
  scanf("%d%d", &n, &m);
  int i, a, b;
  int compa, compb;
  for (i = 1; i <= n; i++) comp[i] = i;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    vis[a] = vis[b] = 1;
    if (a == b)
      loops++;
    else {
      compa = c(a);
      compb = c(b);
      comp[compa] = compb;
      d[a]++;
      d[b]++;
    }
  }
}
int comps() {
  int cc = 0;
  int i;
  for (i = 1; i <= n; i++) {
    if (c(i) == i && vis[i] != 0) cc++;
  }
  return cc;
}
void solve() {
  if (comps() > 1) return;
  int i;
  rez = 0;
  rez += 1LL * loops * (loops - 1) / 2;
  rez += 1LL * loops * (m - loops);
  for (i = 1; i <= n; i++) {
    if (d[i] != 0) rez += 1LL * d[i] * (d[i] - 1) / 2;
  }
}
void printFile() { printf("%lld\n", rez); }
int main() {
  readFile();
  solve();
  printFile();
  return 0;
}
