#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % 1000000007;
    }
    b /= 2;
    a = (a * a) % 1000000007;
  }
  return res;
}
const long long N = 1e6 + 6;
long long n, m, x, y, loop, ans, cc;
vector<long long> g[N];
bool vis[N];
bool contain[N];
void dfs(long long v) {
  vis[v] = 1;
  for (long long x : g[v])
    if (!vis[x]) dfs(x);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (__typeof(m) i = 1; i <= m; i++) {
    cin >> x >> y;
    if (x == y) {
      loop++;
      contain[x] = 1;
    } else {
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  for (__typeof(n) i = 1; i <= n; i++)
    if (!vis[i] && (g[i].size() || contain[i])) {
      cc++;
      dfs(i);
    }
  if (cc > 1) {
    cout << 0;
    return 0;
  }
  for (__typeof(n) i = 1; i <= n; i++) {
    long long edges = g[i].size();
    ans += (edges * (edges - 1)) / 2;
  }
  ans += loop * (m - loop) + (loop * (loop - 1)) / 2;
  cout << ans << endl;
  return 0;
}
