#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 22;
long long n, t, m;
long long res, tmp[N], sum;
vector<long long> G[N];
bool mark[N];
void dfs(int v) {
  mark[v] = true;
  t += G[v].size();
  t += tmp[v] * 2;
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (!mark[u]) dfs(u);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if (x == y) {
      tmp[x]++;
      sum++;
      continue;
    }
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (G[i].size() != 0) {
      dfs(i);
      break;
    }
  }
  if (t != 2 * m) return cout << 0, 0;
  for (int i = 1; i <= n; i++) {
    long long x = G[i].size();
    res += (x * (x - 1) / 2);
  }
  res += sum * (m - sum) + sum * (sum - 1) / 2;
  cout << res;
  return 0;
}
