#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 3;
vector<int> v[N];
int long long same = 0;
int long long degree[N] = {0};
int vis[N] = {0};
int isthere[N] = {0};
void dfs(int ver) {
  vis[ver] = 1;
  for (int i = 0; i < v[ver].size(); i++) {
    if (vis[v[ver][i]] == 0) {
      dfs(v[ver][i]);
    }
  }
}
int long long nc2(int long long num) { return 1LL * ((num * (num - 1)) / 2); }
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int i;
  int num = 0;
  for (i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    isthere[x] = 1;
    isthere[y] = 1;
    num = x;
    if (x == y) {
      same++;
    } else {
      v[x].push_back(y);
      v[y].push_back(x);
      degree[x]++;
      degree[y]++;
    }
  }
  dfs(num);
  int long long ans = 1LL * same * (m - same);
  ans = 1LL * (ans + 1LL * nc2(same));
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0 && isthere[i]) {
      printf("0\n");
      return 0;
    }
    ans = 1LL * (ans + 1LL * nc2(degree[i]));
  }
  printf("%lld\n", ans);
  return 0;
}
