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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ST first
#define ND second
#define PB push_back
#define SIZE(a) ((int)a.size())

template<class T, class U>
ostream& operator<<(ostream &stream, pair<T, U> &p) {
    stream << "(" << p.ST << "," << p.ND << ")";
    return stream;
}

template<class T>
ostream& operator<<(ostream &stream, vector<T> &v) {
    stream << "[";
    for(auto elem : v) {
        stream << elem << ", ";
    }
    stream << "]";
    return stream;
}

ll res;

vector<vector<pii>> v;
vector<bool> vis;
vector<int> low, pre;
int n, m;

pii dfs(int a, int peid, int eid, int &num) {
    pii r = {1, 0};
    vis[a] = true;
    pre[a] = num++;
    low[a] = pre[a];
    for(auto x : v[a]) {
        if(x.ND == peid) {
            continue;
        }
        int b = x.ST;
        if(vis[b]) {
            low[a] = min(low[a], pre[b]);
        } else {
            pii q = dfs(b, x.ND, eid, num);
            r.ST+=q.ST;
            r.ND+=q.ND;
            low[a] = min(low[a], low[b]);
        }
    }
    if(peid > eid && low[a] == pre[a]) {
        // cout << a << " " << peid << "\n";
        r.ND++;
    }
    return r;
}

void create_graph(vector<pii> &e, int a, int b) {
    for(int i=1; i <= n; i++) {
        v[i].clear();
    }
    for(int i=0; i < SIZE(e); i++) {
        if(i == a || i == b) {
            continue;
        }
        pii x = e[i];
        v[x.ST].PB({x.ND, i});
        v[x.ND].PB({x.ST, i});
    }
    for(int i=1; i <= n; i++) {
        vis[i] = false;
    }
    int num = 0;
    auto r = dfs(1, -1, b, num);
    if(r.ST < n) {
        res+=(m-b-1);
    } else {
        res+=r.ND;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    v.resize(n+1);
    vis.resize(n+1);
    low.resize(n+1);
    pre.resize(n+1);
    vector<pii> e(m);
    for(int i=0; i < m; i++) {
        cin >> e[i].ST >> e[i].ND;
    }
    for(int i=0; i < m; i++) {
        for(int j=i+1; j < m; j++) {
            create_graph(e, i, j);
        }
    }
    cout << res << "\n";
}