import sys sys.setrecursionlimit(10**8) N = int(input()) G = [list() for _ in range(N)] for i in range(N-1): a, b = map(int, input().split()) a-=1;b-=1 G[a].append(b) G[b].append(a) dp = [[-1]*2 for _ in range(N)] def dfs(v, p): if len(G[v])==1 and p!=-1: dp[v][0] = 1 dp[v][1] = 0 return f = 0 sm1, sm2 = 0, 0 for nex in G[v]: if nex==p: continue if dp[nex][0] == -1: dfs(nex, v) sm1 += max(dp[nex]) sm2 += dp[nex][1] f = max(dp[nex][0]-dp[nex][1], f) dp[v][1] = sm1 dp[v][0] = sm2+max(f, 1) dfs(0, -1) print(max(dp[0]))