#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 2e6, M = N;
vector<int> g[N];
int a[N], vis[N], s[N];
int tot = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, n, k, j, m, cnt = 0;
  cin >> n >> m;
  ipgraph(m);
  for (i = 1; 1 < n + 1 ? i < n + 1 : i > n + 1; 1 < n + 1 ? i += 1 : i -= 1)
    if (s[i]) {
      dfs(i, 0);
      break;
    }
  for (i = 0; i < n; i++)
    if (s[i + 1] and !vis[i + 1]) cnt = 1;
  if (cnt) {
    cout << "0" << endl;
    return 0;
  }
  long long ans = tot * 1LL * (m - tot) + (tot * 1LL * (tot - 1)) / 2;
  for (i = 1; 1 < n + 1 ? i < n + 1 : i > n + 1; 1 < n + 1 ? i += 1 : i -= 1) {
    long long x = g[i].size();
    ans += (x * (x - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(int m) {
  int i, u, v;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    u++, v++;
    s[u - 1]++, s[v - 1]++;
    if (u == v)
      tot++;
    else {
      g[u - 1].push_back(v - 1);
      g[v - 1].push_back(u - 1);
    }
  }
}
void dfs(int u, int par) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (vis[v]) continue;
    dfs(v, u);
  }
}
