#include <bits/stdc++.h>
using namespace std;
long long md = 1e9 + 7;
long long md2 = 1e9 + 9;
vector<int> graf[1000010];
bool vis[1000010];
int n, m, edges;
long long step[1000010];
long long loops;
long long norm_edge;
long long ans = 0;
void dfs(int v) {
  if (vis[v]) return;
  vis[v] = true;
  for (int i(0); i < graf[v].size(); i++) {
    edges++;
    dfs(graf[v][i]);
  }
}
long long get_ans(long long xx, long long lp, long long nre) {
  return (xx + nre * lp + ((lp * (lp - 1)) / 2));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i(1); i <= m; i++) {
    int x, y;
    cin >> x >> y;
    graf[x].push_back(y);
    graf[y].push_back(x);
    if (x != y) {
      step[x]++;
      step[y]++;
      norm_edge++;
    } else
      loops++;
  }
  for (int i(1); i <= n + 1; i++) ans += (step[i] * (step[i] - 1) / 2);
  for (int i(1); i <= n; i++) {
    edges = 0;
    dfs(i);
    if (edges != m * 2 && edges != 0) return cout << 0, 0;
  }
  cout << get_ans(ans, loops, norm_edge) << "\n";
}
