#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 1;
const int INF = 1e18 + 9;
const int B = 1e9 + 7;
int u[N];
vector<int> g[N];
void dfs(int x) {
  if (u[x]) return;
  u[x] = 1;
  for (auto to : g[x]) dfs(to);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> d(n + 1), c(n + 1);
  for (int i = int(1); i <= int(m); ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      ++c[a];
      continue;
    }
    ++d[a];
    g[a].push_back(b);
    ++d[b], g[b].push_back(a);
  }
  for (int i = int(1); i <= int(n); ++i)
    if (d[i] || c[i]) {
      dfs(i);
      break;
    }
  for (int i = int(1); i <= int(n); ++i)
    if (!u[i] && (d[i] || c[i])) return 0 * printf("0\n");
  long long ans = 0;
  for (int i = int(1); i <= int(n); ++i)
    if (d[i]) ans += (1ll * d[i] * (d[i] - 1)) / 2;
  long long C = 0;
  for (int i = int(1); i <= int(n); ++i)
    if (c[i]) ++C;
  for (int i = int(1); i <= int(n); ++i)
    if (c[i]) ans += (c[i] * (m - C));
  if (C) ans += (C * (C - 1)) / 2;
  cout << ans << "\n";
  return 0;
}
