#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<vector<int>> g(n + 1);
  long long loop = 0;
  vector<bool> loop_v(n + 1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (a != b) {
      g[a].push_back(b);
      g[b].push_back(a);
    } else {
      g[a].push_back(b);
      loop_v[a] = true;
      ++loop;
    }
  }
  vector<int> color;
  for (int i = 0; i <= n; ++i) {
    color.push_back(0);
  }
  int number_of_anj_comp = 0;
  vector<int> stack;
  for (int i = 1; i < n + 1; ++i) {
    if (color[i] == 0) {
      stack.push_back(i);
      int edges = 0;
      while (stack.size() != 0) {
        int v = stack.back();
        stack.pop_back();
        if (color[v] == 0) {
          color[v] = 1;
          for (auto& u : g[v]) {
            edges += 1;
            stack.push_back(u);
          }
          color[v] = 2;
        }
      }
      if (edges > 0) {
        number_of_anj_comp += 1;
      }
    }
  }
  if (number_of_anj_comp > 1) {
    cout << 0;
  } else {
    long long ans = 0;
    for (int i = 1; i < n + 1; ++i) {
      long long k = g[i].size();
      if (loop_v[i]) {
        k -= 1;
      }
      ans += k * (k - 1) / 2;
    }
    ans += (m - loop) * loop + loop * (loop - 1) / 2;
    cout << ans;
  }
  return 0;
}
