def main(): N = int(input()) G = [[] for _ in range(N + 5)] for i in range(N - 1): u, v = map(int, input().split()) G[u].append(v) G[v].append(u) dp = [[0] * 5 for _ in range(N + 5)] root = 1 dfs(root, -1, G, dp) ans = max(dp[root][0], dp[root][1]) print(f"{ans}") return def dfs(u, parent, G, dp): dp[u][0], dp[u][1] = 1, 0 for v in G[u]: if v == parent: continue dfs(v, u, G, dp) dp[u][0] += max(dp[v][0] - 1, dp[v][1]) dp[u][1] += max(dp[v][0], dp[v][1]) return if __name__ == '__main__': main()