#include <bits/stdc++.h>
using namespace std;
long long ans;
int n, m, zihuan;
int v[2000010], next1[2000010], first[2000010], e;
void AddEdge(int U, int V) {
  v[++e] = V;
  next1[e] = first[U];
  first[U] = e;
}
bool vis[2000010];
void dfs(int U) {
  vis[U] = 1;
  for (int i = first[U]; i; i = next1[i]) {
    if (!vis[v[i]]) {
      dfs(v[i]);
    }
  }
}
int main() {
  int x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if (x == y) {
      ++zihuan;
    }
    AddEdge(x, y);
    AddEdge(y, x);
  }
  for (int i = 1; i <= n; ++i) {
    if (first[i]) {
      dfs(i);
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if ((!vis[i]) && first[i]) {
      puts("0");
      return 0;
    }
  }
  ans = (long long)(zihuan - 1) * (long long)(zihuan) / 2ll +
        (long long)zihuan * (long long)(m - zihuan);
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    for (int j = first[i]; j; j = next1[j]) {
      if (v[j] != i) {
        ++cnt;
      }
    }
    ans += (long long)cnt * (long long)(cnt - 1) / 2ll;
  }
  cout << ans << endl;
  return 0;
}
