#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int mod = 1e9 + 7;
vector<int> G[1500005];
bool vis[1500005];
int d[1500005];
void dfs(int u) {
  vis[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) dfs(v);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int num = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    d[u]++;
    d[v]++;
    if (u != v) {
      G[u].push_back(v);
      G[v].push_back(u);
    } else
      num++;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i]) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && d[i] != 0) return 0 * printf("0\n");
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int x = G[i].size();
    if (x > 1) ans += 1ll * x * (x - 1) / 2;
  }
  if (num > 1) ans += 1ll * num * (num - 1) / 2;
  ans += 1ll * num * (m - num);
  cout << ans << endl;
  return 0;
}
