func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   const int maxm = 3e5 + 10;   vector<pair<int, int> > g[maxn];   stack<int> S;   struct edge {     int x, y;   } e[maxm];   int n, m, cnt, dfn;   int d[maxn], low[maxn], fa[maxn], pre[maxn];   void tarjan(int now, int f) {     d[now] = low[now] = ++dfn;     S.push(now);     for (int i = 0; i < g[now].size(); i++) {       int son = g[now][i].first, id = g[now][i].second;       if (id == f) continue;       if (!d[son]) {         fa[son] = now;         tarjan(son, id);         low[now] = min(low[now], low[son]);       } else         low[now] = min(low[now], d[son]);     }     if (low[now] > d[fa[now]]) {       cnt++;       while (!S.empty()) {         int x = S.top();         pre[x] = cnt;         S.pop();         if (x == now) break;       }     }   }   int pos, far;   void dfs(int now, int f, int dep) {     if (dep > far) {       far = dep;       pos = now;     }     for (int i = 0; i < g[now].size(); i++) {       int son = g[now][i].first;       if (son == f) continue;       dfs(son, now, dep + 1);     }   }   void init() {     dfn = cnt = 0;     while (!S.empty()) S.pop();     memset(d, 0, sizeof d);     memset(low, 0, sizeof low);     for (int i = 1; i <= n; i++) g[i].clear();   }   void input() {     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       g[x].push_back({y, i});       g[y].push_back({x, i});       e[i] = (edge){x, y};     }   }   int main() {     while (cin >> n >> m) {       if (n == 0 && m == 0) break;       init();       input();       tarjan(1, 0);       for (int i = 1; i <= n; i++) g[i].clear();       for (int i = 1; i <= m; i++) {         int u = e[i].x, v = e[i].y;         if (pre[u] != pre[v]) {           u = pre[u];           v = pre[v];           g[u].push_back({v, 0});           g[v].push_back({u, 0});         }       }       far = pos = 0;       dfs(1, 0, 0);       int s = pos;       far = pos = 0;       dfs(s, 0, 0);       cout << far << endl;     }     return 0;   }   