#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 6;
vector<int> adj[M];
int mark[M];
int ok[M];
void dfs(int v) {
  mark[v] = 1;
  for (auto u : adj[v])
    if (!mark[u]) dfs(u);
}
int32_t main() {
  long long n, m;
  cin >> n >> m;
  long long r = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    ok[u] = 1, ok[v] = 1;
    if (u != v) adj[u].push_back(v);
    if (u != v) adj[v].push_back(u);
    if (u == v) r++;
  }
  for (int i = 1; i <= n; i++)
    if (ok[i]) {
      dfs(i);
      break;
    }
  for (int i = 1; i <= n; i++)
    if (!mark[i] && ok[i]) return cout << 0 << endl, 0;
  long long ans = r * (m - 1) - ((r) * (r - 1) / 2ll);
  for (int i = 1; i <= n; i++) {
    long long p = adj[i].size();
    ans += p * (p - 1) / 2ll;
  }
  return cout << ans << endl, 0;
}
