#include <bits/stdc++.h>
#define ll long long
#define For(i, a, b) for (int i = a; i < b; i++)
using namespace std;
vector<vector<ll>> adj;
vector<ll> sz, tim, low, stck, bcc[200001];
ll bccs = 1, timer = 1, n, ans = 0, N;
void dfs(ll node, ll parent){
N++;
stck.push_back(node);
tim[node] = low[node] = timer++;
for(ll child : adj[node]){
if(child != parent){
if(tim[child]) low[node] = min(low[node], tim[child]);
else{
dfs(child, node);
low[node] = min(low[node], low[child]);
if(tim[node] <= low[child]) {
bcc[node].push_back(n + bccs);
while(!bcc[n + bccs].size() || bcc[n + bccs].back() != child){
bcc[n + bccs].push_back(stck.back());
stck.pop_back();
}
bccs++;
}
}
}
}
}
void combi(ll node){
sz[node] = (node <= n);
for(ll child : bcc[node]){
combi(child);
sz[node] += sz[child];
if(node > n) ans -= bcc[node].size() * sz[child] * (sz[child] - 1);
}
if(node > n) ans -= bcc[node].size() * (N - sz[node]) * (N - sz[node] - 1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
if (freopen("input.txt", "r", stdin) == NULL) {
cerr << "Error: input.txt not found!" << endl;
return 1;
}
#endif*/
ll m;
cin >> n >> m;
adj.resize(n + 1);
For(i,0,m){
ll x, y;
cin >> x >> y;
adj[x].push_back(y);
adj[y].push_back(x);
}
sz.resize(2 * n + 1);
tim.resize(n + 1);
low.resize(n + 1);
For(i,1,n + 1){
if(!tim[i]){
N = 0;
dfs(i, 0);
ans += N*(N - 1)*(N - 2);
combi(i);
}
}
cout << ans;
return 0;
}