#include <bits/stdc++.h>
using namespace std;
int d[1000005];
bool vis[1000005];
vector<pair<int, int> > G[1000005];
void dfs(int u) {
  for (pair<int, int> x : G[u])
    if (!vis[x.first]) {
      vis[x.first] = 1;
      dfs(x.second);
    }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  long long ans = 0;
  int tmp;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    tmp = x;
    if (x == y)
      ans++;
    else
      d[x]++, d[y]++;
    G[x].push_back(make_pair(i, y));
    G[y].push_back(make_pair(i, x));
  }
  dfs(tmp);
  bool test = 1;
  for (int i = 0; i < m; i++)
    if (!vis[i]) {
      test = 0;
      break;
    }
  if (test) {
    ans = ans * (m - 1) - ans * (ans - 1) / 2;
    for (int i = 1; i <= n; i++) ans += (long long)d[i] * (d[i] - 1) / 2;
    printf("%I64d\n", ans);
  } else
    puts("0");
  return 0;
}
