#include <bits/stdc++.h>
using namespace std;
int vis[1000000], num[1000000], mark[1000000];
vector<int> g[1000000];
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < num[x] - mark[x]; i++)
    if (vis[g[x][i]] == 0) dfs(g[x][i]);
  return;
}
int main() {
  memset(vis, 0, sizeof(vis));
  int n, m, loop = 0;
  memset(mark, 0, sizeof(mark));
  long long ans = 0;
  memset(num, 0, sizeof(num));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    if (x == y) {
      num[x]++;
      loop++;
      mark[x] = 1;
    } else {
      num[x]++;
      num[y]++;
      g[x].push_back(y);
      g[y].push_back(x);
    }
  }
  for (int i = 0; i < n; i++)
    if (num[i] != 0) {
      dfs(i);
      break;
    }
  for (int i = 0; i < n; i++)
    if (vis[i] == 0 && num[i] != 0) {
      cout << 0 << endl;
      return 0;
    }
  for (int i = 0; i < n; i++) {
    if (mark[i] == 1) num[i]--;
    ans += ((long long)num[i] * ((long long)num[i] - 1)) / 2;
  }
  ans += ((long long)loop * (long long)(loop - 1)) / 2;
  ans += (long long)loop * (long long)(m - loop);
  cout << ans << endl;
  return 0;
}
