#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
long long n, m, loop;
long long ans;
vector<long long> v[N];
bool mark[N], hasloop[N];
long long was;
void dfs(long long s, bool first) {
  mark[s] = true;
  bool flag = false;
  for (long long i = 0; i < v[s].size(); ++i)
    if (!mark[v[s][i]]) {
      dfs(v[s][i], false);
      flag = true;
    }
  if (first) was += (long long)(flag or hasloop[s]);
}
int32_t main() {
  cin >> n >> m;
  long long x, u;
  for (long long i = 0; i < m; ++i) {
    scanf("%lld%lld", &x, &u);
    if (x == u) {
      loop++;
      hasloop[x] = true;
    } else {
      v[x].push_back(u);
      v[u].push_back(x);
    }
  }
  for (long long i = 1; i <= n; ++i)
    if (!mark[i]) {
      dfs(i, true);
      if (was == 2) return cout << 0, 0;
    }
  for (long long i = 1; i <= n; ++i)
    ans += (long long)v[i].size() * ((long long)v[i].size() - 1) / 2;
  ans += (loop * (m - 1));
  ans -= (loop * (loop - 1)) / 2;
  cout << ans;
}
