#include <bits/stdc++.h>
const int N = 200005;
using namespace std;
vector<pair<int, int>> edges;
vector<int> adj[N];
int low[N], num[N], cnt[N], parent[N], sz[N];
bool isBridge[N];
int n, m, timer, cntBridge, cc;
void dfs(int u) {
num[u] = ++timer;
low[u] = num[u];
cnt[cc]++;
sz[u] = 1;
for (int v : adj[u]) {
if (v == parent[u])
continue;
if (num[v]) {
low[u] = min(low[u], num[v]);
} else {
parent[v] = u;
dfs(v);
low[u] = min(low[u], low[v]);
sz[u] += sz[v];
if (low[v] > num[u]) {
cntBridge++;
isBridge[v] = true;
}
}
}
}
long long solve() {
if (cc > 2)
return 0;
if (cc == 2)
return (long long)cnt[1] * cnt[2] * (m - cntBridge);
long long ans = 0;
long long maxE = (long long)n * (n - 1) / 2;
for (const auto &edge : edges) {
int u = edge.first;
int v = edge.second;
if (num[u] > num[v])
swap(u, v);
if (parent[v] == u && isBridge[v]) {
ans += (long long)sz[v] * (sz[1] - sz[v]) - 1;
} else {
ans += maxE - m;
}
}
return ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
edges.push_back({u, v});
}
for (int i = 1; i <= n; i++) {
if (num[i] == 0) {
cc++;
dfs(i);
}
}
cout << solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgpjb25zdCBpbnQgTiA9IDIwMDAwNTsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvcjxwYWlyPGludCwgaW50Pj4gZWRnZXM7CnZlY3RvcjxpbnQ+IGFkaltOXTsKaW50IGxvd1tOXSwgbnVtW05dLCBjbnRbTl0sIHBhcmVudFtOXSwgc3pbTl07CmJvb2wgaXNCcmlkZ2VbTl07CmludCBuLCBtLCB0aW1lciwgY250QnJpZGdlLCBjYzsKCnZvaWQgZGZzKGludCB1KSB7CiAgbnVtW3VdID0gKyt0aW1lcjsKICBsb3dbdV0gPSBudW1bdV07CiAgY250W2NjXSsrOwogIHN6W3VdID0gMTsKCiAgZm9yIChpbnQgdiA6IGFkalt1XSkgewogICAgaWYgKHYgPT0gcGFyZW50W3VdKQogICAgICBjb250aW51ZTsKCiAgICBpZiAobnVtW3ZdKSB7CiAgICAgIGxvd1t1XSA9IG1pbihsb3dbdV0sIG51bVt2XSk7CiAgICB9IGVsc2UgewogICAgICBwYXJlbnRbdl0gPSB1OwogICAgICBkZnModik7CiAgICAgIGxvd1t1XSA9IG1pbihsb3dbdV0sIGxvd1t2XSk7CiAgICAgIHN6W3VdICs9IHN6W3ZdOwoKICAgICAgaWYgKGxvd1t2XSA+IG51bVt1XSkgewogICAgICAgIGNudEJyaWRnZSsrOwogICAgICAgIGlzQnJpZGdlW3ZdID0gdHJ1ZTsKICAgICAgfQogICAgfQogIH0KfQoKbG9uZyBsb25nIHNvbHZlKCkgewogIGlmIChjYyA+IDIpCiAgICByZXR1cm4gMDsKICBpZiAoY2MgPT0gMikKICAgIHJldHVybiAobG9uZyBsb25nKWNudFsxXSAqIGNudFsyXSAqIChtIC0gY250QnJpZGdlKTsKCiAgbG9uZyBsb25nIGFucyA9IDA7CiAgbG9uZyBsb25nIG1heEUgPSAobG9uZyBsb25nKW4gKiAobiAtIDEpIC8gMjsKCiAgZm9yIChjb25zdCBhdXRvICZlZGdlIDogZWRnZXMpIHsKICAgIGludCB1ID0gZWRnZS5maXJzdDsKICAgIGludCB2ID0gZWRnZS5zZWNvbmQ7CiAgICBpZiAobnVtW3VdID4gbnVtW3ZdKQogICAgICBzd2FwKHUsIHYpOwogICAgaWYgKHBhcmVudFt2XSA9PSB1ICYmIGlzQnJpZGdlW3ZdKSB7CiAgICAgIGFucyArPSAobG9uZyBsb25nKXN6W3ZdICogKHN6WzFdIC0gc3pbdl0pIC0gMTsKICAgIH0gZWxzZSB7CiAgICAgIGFucyArPSBtYXhFIC0gbTsKICAgIH0KICB9CiAgcmV0dXJuIGFuczsKfQoKaW50IG1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