import sys sys.setrecursionlimit(10**7) N = int(input()) tree = [[] for _ in range(N)] for _ in range(N-1): u, v = map(lambda x:int(x)-1, input().split()) tree[u].append(v) tree[v].append(u) dp = [[0] * N for _ in range(2)] dp[0] = [1] * N def dfs(v, p): for nv in tree[v]: if nv == p: continue dfs(nv, v) dp[0][v] += max(dp[0][nv]-1, dp[1][nv]) # eraseしない dp[1][v] += max(dp[0][nv], dp[1][nv]) # eraseする dfs(0, -1) print(max(dp[0][0], dp[1][0]))