#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<int> G[1123456];
bool visited[1123456];
bool loop[1123456];
void dfs(int v) {
  if (visited[v]) return;
  visited[v] = true;
  for (auto it = G[v].begin(); it != G[v].end(); ++it) dfs(*it);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n >> m) {
    long long l = 0;
    memset(G, 0, sizeof(G));
    memset(visited, 0, sizeof(visited));
    memset(loop, 0, sizeof(loop));
    for (int i = (0); i < (m); i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      if (a != b) {
        G[a].push_back(b);
        G[b].push_back(a);
      } else {
        l++;
        loop[a] = true;
      }
    }
    for (int i = (0); i < (n); i++)
      if (((long long)G[i].size())) {
        dfs(i);
        break;
      }
    bool sepuede = true;
    for (int i = (0); i < (n); i++)
      if (!visited[i] and (((long long)G[i].size()) or loop[i])) {
        sepuede = false;
      }
    if (!sepuede)
      cout << 0 << endl;
    else {
      long long res = (m - l) * l + (l * (l - 1)) / 2;
      for (int i = (0); i < (n); i++)
        res +=
            ((((long long)G[i].size())) * (((long long)G[i].size()) - 1)) / 2;
      cout << res << endl;
    }
  }
  return 0;
}
