#include <bits/stdc++.h>
using namespace std;
int n, m;
long long ans;
vector<int> v[1000010];
bool vis[1000010] = {0};
bool vis1[1000010] = {0};
int z[1000010] = {0};
int bfs(int now) {
  queue<int> q;
  q.push(now);
  vis[now] = 1;
  int sum = 0;
  while (!q.empty()) {
    int x = q.front();
    vis1[x] = 1;
    q.pop();
    for (int i = 0; i < v[x].size(); i++) {
      int y = v[x][i];
      if (vis1[y]) continue;
      sum++;
      if (vis[y] == 0) {
        vis[y] = 1;
        q.push(y);
      }
    }
  }
  return sum;
}
int main() {
  cin >> n >> m;
  long long t1 = 0, t2 = 0;
  ans = 0;
  int sub = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == y) {
      t1++;
      z[x]++;
      continue;
    }
    t2++;
    if (sub == 0) sub = x;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int num = 0;
  num += bfs(sub);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) num += z[i];
  }
  if (m < 2 || num != m) {
    cout << 0 << endl;
  } else {
    for (int i = 1; i <= n; i++) {
      long long x = v[i].size();
      ans = ans + x * (x - 1) / 2;
    }
    ans += t1 * t2;
    ans += t1 * (t1 - 1) / 2;
    cout << ans << endl;
  }
}
