#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, k;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
long long arr[N], brr[N];
string str, ss;
vector<int> adj[N];
bool vis[N];
void dfs(int v) {
  if (vis[v]) return;
  vis[v] = true;
  for (int u : adj[v]) dfs(u);
}
long long x = 0;
bool cnt[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    if (u == v) {
      x++;
      cnt[u] = true;
      continue;
    }
    adj[u].push_back(v);
    if (v != u) adj[v].push_back(u);
  }
  long long sol = 0;
  for (int i = 1; i <= n; ++i) {
    sol += (1LL * adj[i].size() * (1LL * adj[i].size() - 1)) / 2LL;
  }
  int root = 1;
  while (adj[root].size() == 0 && !cnt[root]) root++;
  dfs(root);
  sol += (x * (x - 1)) / 2 + x * (m - x);
  for (int i = 1; i <= n; ++i)
    if (!vis[i] && (adj[i].size() > 0 || cnt[i])) sol = 0;
  cout << sol << endl;
  return 0;
}
