n=int(input()) E=[[] for i in range(n)] for i in range(n-1): x,y=map(int,input().split()) x-=1 y-=1 E[x].append(y) E[y].append(x) # 木のHL分解+LCA ROOT=0 QUE=[ROOT] Parent=[-1]*n Parent[ROOT]=n # ROOTの親を定めておく. Child=[[] for i in range(n)] TOP_SORT=[] # トポロジカルソート while QUE: # トポロジカルソートと同時に親を見つける x=QUE.pop() TOP_SORT.append(x) for to in E[x]: if Parent[to]==-1: Parent[to]=x Child[x].append(to) QUE.append(to) DP=[0]*n DP2=[0]*n for x in TOP_SORT[::-1]: if Child[x]==[]: DP[x]=1 DP2[x]=0 else: score=0 for c in Child[x]: score+=max(DP2[c],DP[c]) DP2[x]=score score=0 for c in Child[x]: score+=max(DP2[c],DP[c]-1) DP[x]=score+1 print(max(DP[0],DP2[0]))