#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
vector<int> g[N];
int loop[N], lcnt;
int vis[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = 0; i < g[x].size(); i++) dfs(g[x][i]);
}
int main() {
  scanf("%d%d", &n, &m);
  memset(loop, 0, sizeof(loop));
  memset(vis, 0, sizeof(vis));
  lcnt = 0;
  int root = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == y)
      loop[x]++, lcnt++;
    else {
      g[x].push_back(y);
      g[y].push_back(x);
    }
    root = x;
  }
  dfs(root);
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && (g[i].size() || loop[i])) flag = 0;
  }
  if (!flag) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int sz = g[i].size();
    ans += (long long)sz * (sz - 1) / 2;
  }
  ans += (long long)lcnt * (m - 1);
  ans -= (long long)lcnt * (lcnt - 1) / 2;
  printf("%I64d\n", ans);
  return 0;
}
