#include <bits/stdc++.h>
using namespace std;
long long cl(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
long long max_div[1000001];
vector<long long> prs;
void sieve() {
  for (long long i = 2; i <= 1000000; i++) {
    if (!max_div[i]) {
      for (long long j = i; j <= 1000000; j += i) {
        max_div[j] = i;
      }
    }
  }
  for (long long i = 2; i < 1000001; i++) {
    if (max_div[i] == i) prs.push_back(i);
  }
}
vector<long long> gp[1000005];
bool vis[1000005];
void dfs(long long a) {
  vis[a] = 1;
  for (long long x : gp[a]) {
    if (!vis[x]) dfs(x);
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long l = 0;
  unordered_set<long long> v;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v.insert(x);
    v.insert(y);
    if (x == y) {
      l++;
      continue;
    }
    gp[x].push_back(y);
    gp[y].push_back(x);
  }
  dfs(*(v.begin()));
  for (long long i : v) {
    if (!vis[i]) {
      cout << "0\n";
      return;
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long x = gp[i].size();
    ans += (x * (x - 1)) / 2;
  }
  ans += l * (m - 1) - (l * (l - 1)) / 2;
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  for (long long i = 0; i < t; i++) solve();
  return 0;
}
