func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<vector<long long>> gr;   vector<bool> used;   vector<long long> tin, up;   const long long Nmax = 400000;   long long p[Nmax];   long long sz[Nmax];   long long timer = 0;   long long diametr(long long u, vector<vector<long long>> gr) {     queue<long long> q;     long long n = (long long)(gr.size());     vector<long long> h(n + 1, -1);     q.push(u);     h[u] = 0;     long long ml = u;     while (!q.empty()) {       long long v = q.front();       q.pop();       for (long long x : gr[v]) {         if (h[x] == -1) {           h[x] = h[v] + 1;           if (h[x] > h[ml]) ml = x;           q.push(x);         }       }     }     vector<long long> prev(n + 1, -1);     h.assign(n + 1, -1);     q.push(ml);     h[ml] = 0;     long long ms = ml;     prev[ml] = ml;     while (!q.empty()) {       long long v = q.front();       q.pop();       for (long long x : gr[v]) {         if (prev[x] == -1) {           h[x] = h[v] + 1;           prev[x] = v;           if (h[x] > h[ms]) ms = x;           q.push(x);         }       }     }     vector<long long> res;     while (prev[ms] != ms) {       res.push_back(ms);       ms = prev[ms];     }     res.push_back(ms);     reverse((res).begin(), (res).end());     return (long long)(res.size()) - 1;   }   long long find(long long x) {     if (p[x] != x) {       p[x] = find(p[x]);     }     return p[x];   }   void merge(long long x, long long y) {     x = find(x);     y = find(y);     p[y] = x;   }   void restart(long long N) {     for (long long i = 0; i < N; ++i) {       sz[i] = 1;       p[i] = i;     }   }   vector<pair<long long, long long>> most;   void dfs(long long u, long long p) {     used[u] = true;     tin[u] = timer++;     up[u] = tin[u];     for (long long v : gr[u]) {       if (used[v] && v != p) up[u] = min(up[u], tin[v]);       if (!used[v]) {         dfs(v, u);         up[u] = min(up[u], up[v]);         if (tin[u] < up[v]) {           most.emplace_back(u, v);         } else {           merge(u, v);         }       }     }   }   void solve() {     long long n, m;     cin >> n >> m;     gr.resize(n);     tin.assign(n, 0);     up.assign(n, 0);     used.assign(n, 0);     restart(n);     for (long long i = (0); i < (m); ++i) {       long long u, v;       cin >> u >> v;       u--;       --v;       gr[u].push_back(v);       gr[v].push_back(u);     }     dfs(0, -1);     vector<vector<long long>> gr2(n);     if (most.empty()) {       cout << 0;       return;     }     for (long long i = (0); i < ((long long)(most.size())); ++i) {       long long u = most[i].first, v = most[i].second;       u = find(u);       v = find(v);       gr2[u].push_back(v);       gr2[v].push_back(u);     }     long long v = most[0].first;     v = find(v);     cout << diametr(v, gr2);   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long t;     t = 1;     while (t--) {       solve();     }     return 0;   }   