//并差集求最大秩 //一堆学生间接或直接互为朋友则合并 //人数最多的集和的人数即为最大秩
//不知道为什么G++超时但是C++过了 #include <iostream> using namespace std; int Father[10000001]; int Rank[10000001]; int T; int Max; void Make_Set(int x) { Father[x] = x; Rank[x] = 1; } int Find(int x) { while(x != Father[x]) { x = Father[x]; } return x; } void Union(int x,int y) { x = Find(x); y = Find(y); if(x == y) return; if(Rank[x] > Rank[y]) { Father[y] = x; Rank[x] += Rank[y]; if(Max < Rank[x]) Max = Rank[x]; } else { Father[x] = y; Rank[y] += Rank[x]; if(Max < Rank[y]) Max = Rank[y]; } } int main() { while(cin>>T) { int x,y; Max = 1; for(long i = 0; i <= 10000000; i++) { Make_Set(i); } for(int i = 1; i <= T; i++) { cin>>x>>y; Union(x,y); } cout<<Max<<endl; } return 0; }