N = int(input()) G = [[] for _ in range(N)] for _ in range(N - 1): u,v = map(int,input().split()) u -= 1 v -= 1 G[u].append(v) G[v].append(u) stack = [(0,-1),(~0,-1)] dp = [[0,1] for _ in range(N)] while stack: now,parent = stack.pop() if now < 0: now = ~now for v in G[now]: if v == parent:continue stack.append((v,now)) stack.append((~v,now)) continue for v in G[now]: if v == parent:continue dp[now][0] += max(dp[v]) dp[now][1] += max(dp[v][0],dp[v][1] - 1) print(max(dp[0])) #print(dp)