#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long INFL = 2e18;
const int N = int(1e6) + 5, M = N;
int n, m;
pair<int, int> e[M];
vector<int> adj[N];
bool exist[N];
void enter() {
  cin >> n >> m;
  for (int i = (1), _b = (m); i <= _b; ++i) {
    int u, v;
    cin >> u >> v;
    if (u != v) {
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    e[i] = make_pair(u, v);
    exist[u] = exist[v] = 1;
  }
}
bool vst[N];
void dfs(int u) {
  vst[u] = 1;
  for (int i = (0), _b = (((int)(adj[u]).size())); i < _b; ++i) {
    int v = adj[u][i];
    if (!vst[v]) dfs(v);
  }
}
bool check_adjacency() {
  for (int i = (1), _b = (n); i <= _b; ++i)
    if (exist[i]) {
      dfs(i);
      break;
    }
  for (int i = (1), _b = (n); i <= _b; ++i)
    if (exist[i] && !vst[i]) return false;
  return true;
}
void process() {
  if (!check_adjacency()) {
    cout << 0 << '\n';
    return;
  }
  long long res = 0;
  for (int i = (1), _b = (n); i <= _b; ++i) {
    res += 1LL * ((int)(adj[i]).size()) * (((int)(adj[i]).size()) - 1) / 2;
  }
  int cnt_loop = 0;
  for (int i = (1), _b = (m); i <= _b; ++i)
    if (e[i].first == e[i].second) {
      res += m - 1;
      ++cnt_loop;
    }
  res -= 1LL * cnt_loop * (cnt_loop - 1) / 2;
  cout << res << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  enter();
  process();
  return 0;
}
