import sys sys.setrecursionlimit(10**7) def main(): 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) dp = [[0, 0] for _ in range(N)] #o exist #1 not exist seen = [0]*N def dfs(x): seen[x] = 1 for nx in G[x]: if seen[nx]: continue dfs(nx) dp[x][0] += max(dp[nx]) dp[x][1] += max(dp[nx][0]+1, dp[nx][1]) dfs(0) print(max(dp[0][0]+1, dp[0][1])) main()