N=int(input()) G=[[] for i in range(N)] for i in range(N-1): a,b=map(int,input().split()) G[a-1].append(b-1) G[b-1].append(a-1) from collections import deque S=deque() dist=[-1]*N dist[0]=0 S.append(0) while S: x=S.pop() for y in G[x]: if dist[y]>=0: continue dist[y]=dist[x]+1 S.append(y) T=[{} for i in range(N)] L=[] for i in range(N): L.append((dist[i],i)) dp=[0]*N L.sort(reverse=True) for i in range(N): x=L[i][1] w=0 for y in G[x]: if dist[y]0: w=max(w,l[i-1]+1) if i