#include <bits/stdc++.h>   using namespace std;   static inline void canhazfast() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);   }   template <typename T>   T gcd(T a, T b) {     return b == 0 ? a : gcd(b, a % b);   }   template <typename T>   T extgcd(T a, T b, T &x, T &y) {     T x0 = 1, y0 = 0, x1 = 0, y1 = 1;     while (b) {       T q = a / b;       a %= b;       swap(a, b);       x0 -= q * x1;       swap(x0, x1);       y0 -= q * y1;       swap(y0, y1);     }     x = x0;     y = y0;     return a;   }   static inline int ctz(unsigned x) { return __builtin_ctz(x); }   static inline int ctzll(unsigned long long x) { return __builtin_ctzll(x); }   static inline int clz(unsigned x) { return __builtin_clz(x); }   static inline int clzll(unsigned long long x) { return __builtin_clzll(x); }   static inline int popcnt(unsigned x) { return __builtin_popcount(x); }   static inline int popcntll(unsigned long long x) {     return __builtin_popcountll(x);   }   static inline int bsr(unsigned x) { return 31 ^ clz(x); }   static inline int bsrll(unsigned long long x) { return 63 ^ clzll(x); }   vector<int> adj[300016];   int id[300016], lo[300016];   int par[300016], rnk[300016], dist[300016];   vector<int> tadj[300016];   vector<pair<int, int> > br;   int nxt = 0;   int fin(int x) { return par[x] == x ? x : par[x] = fin(par[x]); }   void uni(int x, int y) {     if (rnk[x] < rnk[y]) {       par[x] = y;     } else {       par[y] = x;       rnk[x] = max(rnk[x], rnk[y] + 1);     }   }   void dfs(int u, int p = 0) {     id[u] = lo[u] = ++nxt;     for (int v : adj[u]) {       if (!id[v]) {         dfs(v, u);         lo[u] = min(lo[u], lo[v]);         if (lo[v] > id[u]) {           br.emplace_back(u, v);         } else {           int ru = fin(u), rv = fin(v);           if (ru != rv) uni(ru, rv);         }       } else if (v != p) {         lo[u] = min(lo[u], lo[v]);       }     }   }   int bfs(int s, int n) {     queue<int> q;     int r = 0;     fill_n(dist + 1, n, 1010101);     dist[s] = 0;     q.push(s);     while (!q.empty()) {       int u = q.front();       q.pop();       r = u;       for (int v : tadj[u]) {         if (dist[u] + 1 < dist[v]) {           dist[v] = dist[u] + 1;           q.push(v);         }       }     }     return r;   }   int main() {     canhazfast();     int n, m, t;     cin >> n >> m;     for (int i = 1; i <= n; ++i) par[i] = i;     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(1);     for (pair<int, int> e : br) {       int a = fin(e.first), b = fin(e.second);       tadj[a].push_back(b);       tadj[b].push_back(a);     }     t = bfs(fin(1), n);     t = bfs(t, n);     cout << dist[t];     return 0;   }   