#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a;
vector<bool> has;
int cnt;
void dfs(int x) {
  has[x] = false;
  for (int y : a[x]) {
    ++cnt;
    if (has[y]) {
      dfs(y);
    }
  }
}
long long cn2(long long x) { return x * (x - 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  a.resize(n);
  has.resize(n);
  long long res = 0;
  long long loops = 0;
  for (int i = (0); i < (m); ++i) {
    int q, w;
    cin >> q >> w;
    --q, --w;
    has[q] = true;
    has[w] = true;
    if (q == w)
      loops++;
    else {
      a[w].push_back(q);
      a[q].push_back(w);
    }
  }
  for (int i = (0); i < (n); ++i)
    if (has[i]) {
      dfs(i);
      break;
    }
  bool bad = count((has).begin(), (has).end(), true);
  if (!bad) {
    for (int i = (0); i < (n); ++i) res += cn2(((int)(a[i]).size()));
    res += cn2(loops);
    res += loops * (m - loops);
    cout << res << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
