#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
vector<int> adjL[N];
bool vis[N], hasLoop[N];
void DFS(int node) {
  if (vis[node]) return;
  vis[node] = true;
  for (int ch : adjL[node]) DFS(ch);
}
int main() {
  scanf("%d%d", &n, &m);
  int self = 0;
  for (int i = (1); i <= (int)(m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != b)
      adjL[a].push_back(b), adjL[b].push_back(a);
    else
      ++self, hasLoop[a] = true;
  }
  for (int i = (1); i <= (int)(n); ++i)
    if (hasLoop[i] || ((int)((adjL[i]).size()))) {
      DFS(i);
      break;
    }
  for (int i = (1); i <= (int)(n); ++i)
    if (!vis[i] && (hasLoop[i] || ((int)((adjL[i]).size())) > 0)) {
      printf("0\n");
      return 0;
    }
  long long ans = 0;
  for (int i = (1); i <= (int)(n); ++i)
    ans += 1ll * (((int)((adjL[i]).size())) - 1ll) * ((int)((adjL[i]).size())) /
           2ll;
  ans += 1ll * self * (self - 1ll) / 2ll;
  ans += 1ll * self * (m - self);
  printf("%lld\n", ans);
  return 0;
}
