#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
int d[1000005];
vector<int> mp[1000005];
bool vis[1000005], sf[1000005];
void dfs(int x) {
  vis[x] = 1;
  for (int c : mp[x])
    if (!vis[c]) dfs(c);
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  int es = 0;
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    sf[u] = 1;
    sf[v] = 1;
    if (u == v) {
      continue;
    }
    es++;
    d[u]++;
    d[v]++;
    mp[u].push_back(v);
    mp[v].push_back(u);
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (sf[i]) {
      dfs(i);
      break;
    }
  for (int(i) = 1; (i) <= (int)(n); (i)++)
    if (sf[i] && !vis[i]) {
      puts("0");
      return;
    }
  long long ans = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    ans += (long long)d[i] * (d[i] - 1) / 2;
  }
  ans += (long long)es * (m - es);
  if (m - es > 0) {
    ans += (long long)(m - es) * (m - es - 1) / 2;
  }
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
