#include<cstdio> usingnamespace std; template <classType> voidread(Type &x) { char c; bool flag = false; while ((c = getchar()) < '0' || c > '9') flag |= c == '-'; x = c - '0'; while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0'; if (flag) x = ~x + 1; } template <classType, class ...Rest> voidread(Type &x, Rest &...y){ read(x); read(y...); } template <classType> voidwrite(Type x) { if (x < 0) putchar('-'), x = ~x + 1; if (x > 9) write(x / 10); putchar('0' + x % 10); } typedeflonglong LL; constint N = 1e6 + 10; bool vis[N]; int n, m, p[N], d[N]; intfa(int x){ return p[x] == x ? x : p[x] = fa(p[x]); } intmain() { read(n, m); for (int i = 1; i <= n; ++i) p[i] = i; int t = 0; for (int i = 1, a, b; i <= m; ++i) { read(a, b); vis[a] = vis[b] = true; if (a == b) ++t; else ++d[a], ++d[b], p[fa(a)] = fa(b); } int tot = 0; for (int i = 1; i <= n; ++i) tot += vis[i] && p[i] == i; if (tot > 1) returnputs("0"), 0; LL res = (LL)(t - 1) * t / 2 + (LL)t * (m - t); for (int i = 1; i <= n; ++i) res += (LL)d[i] * (d[i] - 1) / 2; write(res); return0; }