#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  long long int r, i;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long int power(long long int x, long long int y, long long int mod) {
  long long int temp, ty, my;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod);
  ty = (temp % mod) * (temp % mod);
  if (y % 2 == 0) {
    return ty % mod;
  } else {
    my = (x % mod) * (ty % mod);
    return my % mod;
  }
}
long long int mycbrt(long long int n) {
  long long int start = 0;
  long long int end = 1000000LL;
  long long int ans = -1;
  while (start <= end) {
    long long int mid = (start + end) / 2;
    if ((mid * mid * mid) > n)
      end = mid - 1;
    else if ((mid * mid * mid) == n) {
      ans = mid;
      break;
    } else {
      start = mid + 1;
    }
  }
  if (n == 1) {
    ans = 1;
  }
  return ans;
}
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) cout << p << " ";
}
struct abhi {
  long long int val1;
  long long int val2;
  long long int po;
};
bool cmp(struct abhi x, struct abhi y) {
  if (x.val1 == y.val1) return x.val2 < y.val2;
  return x.val1 < y.val1;
}
void fastscan(int& number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2>& p) const {
    auto hash1 = hash<T1>()(p.first);
    auto hash2 = hash<T2>()(p.second);
    return hash1 ^ hash2;
  }
};
unordered_map<pair<long long int, long long int>, long long int, hash_pair> mp;
long long int base = 10;
vector<long long int> num;
void convertTobase(long long int inputNum) {
  while (inputNum > 0) {
    num.push_back(inputNum % base);
    inputNum /= base;
  }
  reverse(num.begin(), num.end());
}
int parent[10009];
int rankVal[10009];
void init(int n) {
  for (int i = 0; i <= n + 1; i++) {
    parent[i] = i;
    rankVal[i] = 0;
  }
}
int find(int v) {
  if (parent[v] == v) return v;
  return parent[v] = find(parent[v]);
}
void union_set(int u, int v) {
  u = find(u);
  v = find(v);
  if (rankVal[u] == rankVal[v]) {
    parent[u] = v;
    rankVal[v]++;
  } else {
    if (rankVal[u] > rankVal[v])
      parent[v] = u;
    else
      parent[u] = v;
  }
}
vector<pair<long long int, long long int> > po;
long long int vis[1000010];
vector<long long int> bc[1000010];
vector<long long int> gc[1000010];
long long int n, m;
void dfs(long long int st) {
  vis[st] = 1;
  long long int i, j, k;
  for (long long int x : bc[st]) {
    if (vis[x] == 0) {
      dfs(x);
    }
  }
}
int main() {
  int start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, k, a, b, s, q;
  long long int t;
  cin >> n >> m;
  long long int cn = 0;
  for (i = (0); i < (m); i++) {
    cin >> a >> b;
    if (a != b) {
      bc[a].push_back(b);
      bc[b].push_back(a);
      gc[a].push_back(b);
      gc[b].push_back(a);
    } else {
      cn++;
      gc[a].push_back(b);
    }
  }
  long long int fg = 0;
  for (i = (1); i < (n + 1); i++) {
    if (vis[i] == 0 && gc[i].size() > 0) {
      fg++;
      if (fg == 2LL) {
        break;
      }
      dfs(i);
    }
  }
  if (fg == 2) {
    cout << "0\n";
    return 0;
  }
  long long int ans = 0;
  for (i = (1); i < (n + 1); i++) {
    long long int nu = bc[i].size();
    ans = ans + (nu * (nu - 1)) / 2;
  }
  ans = ans + cn * (m - 1) - ((cn * (cn - 1)) / 2);
  cout << ans << "\n";
  return 0;
}
