#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
const int M = 998244353;
long long deg[N], sl = 0, cnt = 0;
vector<int> v[N];
bool pres[N];
bool vis[N];
void dfs(int node) {
  vis[node] = true;
  cnt++;
  for (int x : v[node]) {
    if (!vis[x]) {
      dfs(x);
    }
  }
}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    pres[x] = true;
    pres[y] = true;
    if (x == y) {
      sl++;
    } else {
      deg[x]++;
      deg[y]++;
      v[x].push_back(y);
      v[y].push_back(x);
    }
  }
  int tot = 0;
  for (int i = 1; i < n + 1; i++) {
    if (pres[i]) {
      tot++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (pres[i] && !vis[i]) {
      dfs(i);
      if (cnt != tot) {
        cout << "0" << endl;
        return 0;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) {
    ans = ans + (deg[i] * (deg[i] - 1)) / 2;
  }
  ans = ans + sl * (m - sl);
  ans = ans + ((sl) * (sl - 1)) / 2;
  printf("%lld\n", ans);
  return 0;
}
