#include using namespace std; using ll=long long; using ld=long double; using P=pair; using V=vector; #define rep(i,n) for(int i=0;i> n >> m; V u(m),v(m); rep(i,m){ cin >> u[i] >> v[i]; u[i]--; v[i]--; } reverse(u.begin(),u.end()); reverse(v.begin(),v.end()); V a(n); ll ans=0; rep(i,m){ a[root(u[i])]=a[root(v[i])]=max(a[root(u[i])],a[root(v[i])])+1; unite(u[i],v[i]); } rep(i,n) ans=max(ans,a[i]); cout << ans << endl; }