#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adia[1000010];
vector<pair<int, int>> muchii;
int tata[1000010];
bool folosit[1000010];
int g[1000010];
int find(int nod);
void unite(int a, int b);
int main() {
  ios_base ::sync_with_stdio(0);
  int n, a, b, m;
  cin >> n >> m;
  for (int i(1); i <= n; i++) tata[i] = i, g[i] = 1;
  int de = 0;
  while (m--) {
    cin >> a >> b;
    unite(a, b);
    int x = 0;
    folosit[a] = folosit[b] = 1;
    if (a != b) adia[a].push_back({b, x});
    if (a != b)
      adia[b].push_back({a, x});
    else
      de++;
    muchii.push_back({a, b});
  }
  int x = 0;
  for (int i(1); i <= n; i++) {
    if (!folosit[i]) continue;
    int y = find(i);
    if (x == 0)
      x = y;
    else if (x != y) {
      cout << 0;
      return 0;
    }
  }
  long long ans(1ll * de * (muchii.size() - de) + 1ll * de * (de - 1) / 2);
  for (int i(1); i <= n; i++) {
    ans += 1ll * adia[i].size() * (adia[i].size() - 1) / 2;
  }
  cout << ans;
  return 0;
}
void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (g[a] > g[b])
    g[a] += g[b], tata[b] = a;
  else
    g[b] += g[a], tata[a] = b;
}
int find(int nod) {
  if (tata[tata[nod]] != tata[nod]) tata[nod] = find(tata[tata[nod]]);
  return tata[nod];
}
