#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e9 + 7);
long long modpow(long long a, long long b) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2) * (b & 1 ? a : 1) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  long long sl = 0;
  int smth = 0;
  vector<pair<int, int> > edges;
  vector<int> adj[n];
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    if (--x == --y)
      sl++;
    else {
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    edges.push_back(pair<int, int>(x, y));
    smth = x;
  }
  vector<int> pq;
  pq.push_back(smth);
  bool visited[n];
  memset(visited, false, sizeof(visited));
  visited[smth] = true;
  while (!pq.empty()) {
    int v = pq.back();
    pq.pop_back();
    for (int w : adj[v]) {
      if (!visited[w]) {
        visited[w] = true;
        pq.push_back(w);
      }
    }
  }
  bool conn = true;
  for (pair<int, int> edge : edges)
    conn &= visited[edge.first] && visited[edge.second];
  if (!conn)
    cout << 0 << endl;
  else {
    long long ans = 0;
    for (int i = 0; i < n; i++)
      ans += 1LL * adj[i].size() * (adj[i].size() - 1) / 2;
    ans += 1LL * sl * (m - 1) - 1LL * sl * (sl - 1) / 2;
    cout << ans << endl;
  }
  return 0;
}
