import sys sys.setrecursionlimit(100000+10) from collections import deque N = int(input()) G = {i:[] for i in range(1,N+1)} for _ in range(N-1): u,v = map(int,input().split()) G[u].append(v) G[v].append(u) deg = [0]*(N+1) P = [0]*(N+1) def dfs(x,p): for y in G[x]: if y==p:continue deg[x] += 1 P[y] = x dfs(y,x) dfs(1,0) dp = [0]*(N+1) deg1 = deg[:] que = deque([]) for i in range(1,N+1): if deg[i]==0: que.append(i) F = [0]*(N+1) while que: x = que.popleft() if deg[x]==0: dp[x] = 1 else: dp[x] = F[x] cnt = 1 for y in G[x]: if y==P[x]:continue cnt += F[y] dp[x] = max(dp[x],cnt) F[P[x]] += dp[x] deg1[P[x]] -= 1 if deg1[P[x]]==0: que.append(P[x]) print(dp[1])