#include using namespace std; #include using namespace atcoder; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n+1); i++) #define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++) #define repv(i, n) for (ll i = (ll)(n-1); i >= 0; i--) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) ((int)(x).size()) #define cauto const auto& #define bit(n) (1LL<<(n)) #define uni(v) v.erase( unique(v.begin(), v.end()), v.end() ); using ll = long long; using P = pair; using PP = pair; using Graph = vector>; using mint = modint998244353; #ifdef LOCAL #include #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif int main(){ ll n,m; cin >> n >> m; vector

uv; rep(i,m){ ll u,v; cin >> u >> v; u--; v--; uv.push_back({u,v}); } dsu d(n); vector ans(n,0); repv(i,m){ if(d.same(uv[i].first,uv[i].second)){ ans[d.leader(uv[i].first)]++; continue; } ll tmp1 = d.leader(uv[i].first); ll tmp2 = d.leader(uv[i].second); d.merge(uv[i].first,uv[i].second); ans[d.leader(uv[i].first)] = max(ans[tmp1] ,ans[tmp2])+1; } cout << ans[d.leader(uv[0].first)] << endl; return 0; }