#include <bits/stdc++.h>
using namespace std;
int64_t n, m, cnt = 0;
vector<vector<int64_t> > v;
void rec(int64_t t, vector<char> &ch) {
  if (ch[t]) return;
  ch[t] = true;
  for (int64_t i = 0; i < v[t].size(); ++i) rec(v[t][i], ch);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  v.resize(n);
  vector<pair<int64_t, int64_t> > d;
  vector<char> r(n, false);
  for (int64_t i = 0; i < m; ++i) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a == b) {
      ++cnt;
      r[a] = true;
      continue;
    }
    d.push_back({a, b});
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vector<char> ch(n, false);
  int64_t o = 0;
  for (int64_t i = 0; i < n; ++i) {
    if ((v[i].size() || r[i]) && !ch[i]) {
      rec(i, ch);
      ++o;
    }
  }
  if (o > 1) {
    cout << 0;
    return 0;
  }
  m -= cnt;
  int64_t ans = cnt * m + cnt * (cnt - 1) / 2, ans2 = 0;
  for (int64_t i = 0; i < d.size(); ++i) {
    ans2 += v[d[i].first].size() + v[d[i].second].size() - 2;
  }
  cout << ans + ans2 / 2;
}
