1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

#define f first
#define s second

const int MAXN = 2e5 + 13;

int odw[MAXN];
int low[MAXN];
int poz[MAXN];
pair<int, int> e[MAXN];
vector<int> v[MAXN];
int ile, trn = 0;
long long mos;

void DFS(int x, int oj, int lvl) {
    ile++;
    odw[x] = trn;
    low[x] = poz[x] = lvl;
    int coj = 0;
    for (auto &it:v[x]) {
        if (it == oj) {
            coj++;
            continue;
        }
        if (odw[it] == trn)
            low[x] = min(low[x], poz[it]);
        else {
            DFS(it, x, lvl + 1);
            low[x] = min(low[x], low[it]);
        }
    }
    if (coj == 1 && low[x] == poz[x])
        mos++;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    long long ans = 0;
    long long M = m;
    for (int i = 1; i <= m; i++)
        cin >> e[i].f >> e[i].s;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == j)
                continue;
            for (int l = 1; l <= m; l++) {
                if (l != i && l != j) {
                    v[e[l].f].push_back(e[l].s);
                    v[e[l].s].push_back(e[l].f);
                }
            }
            trn++;
            ile = 0;
            mos = 0;
            DFS(1, 0, 1);
            if (ile != n)
                ans += M - 2;
            else
                ans += mos;
            for (int l = 1; l <= n; l++) {
                low[l] = 0;
                v[l].clear();
            }
        }
    }
    cout << ans / 6;
    return 0;
}