#include <bits/stdc++.h>
using namespace std;
long long n, m, ans = 0, loopnum = 0;
vector<int> G[1000010];
bool inG[1000010] = {0};
bool flag[1000010] = {0};
void dfs(long long now) {
  flag[now] = 1;
  for (long long i = 0; i < G[now].size(); i++)
    if (!flag[G[now][i]]) dfs(G[now][i]);
}
int main() {
  long long x, y, i, j;
  scanf("%I64d%I64d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%I64d%I64d", &x, &y);
    inG[x] = 1;
    inG[y] = 1;
    if (x == y)
      loopnum++;
    else {
      G[x].push_back(y);
      G[y].push_back(x);
    }
  }
  dfs(x);
  for (i = 1; i <= n; i++)
    if (inG[i] && !flag[i]) {
      printf("0");
      return 0;
    }
  for (i = 1; i <= n; i++) ans += G[i].size() * (G[i].size() - 1LL) / 2LL;
  ans += loopnum * (m - 1LL) - loopnum * (loopnum - 1LL) / 2LL;
  printf("%I64d", ans);
}
