n = int(input()) edges = [[] for _ in range(n)] for _ in range(n - 1): u, v = map(int, input().split()) u -= 1 v -= 1 edges[u].append(v) edges[v].append(u) stack = [0] order = [0] dist = [-1] * n dist[0] = 0 while stack: pos = stack.pop() for npos in edges[pos]: if dist[npos] != -1: continue dist[npos] = dist[pos] + 1 stack.append(npos) order.append(npos) dp1 = [0] * n dp2 = [1] * n for pos in order[::-1]: for npos in edges[pos]: if dist[npos] < dist[pos]: continue dp1[pos] += max(dp1[npos], dp2[npos]) dp2[pos] += max(dp1[npos], dp2[npos] - 1) print(max(dp1[0], dp2[0]))