from collections import defaultdict import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) def dfs(cur, prev, state): if memo[cur][state] != -1: return memo[cur][state] if state == 0: res = 0 for child in adj_dict[cur]: if prev != child: res += max(dfs(child, cur, 0), dfs(child, cur, 1)) else: res = 1 for child in adj_dict[cur]: if prev != child: res += max(dfs(child, cur, 0), dfs(child, cur, 1) - 1) memo[cur][state] = res return res N = int(input()) adj_dict = defaultdict(list) for _ in range(N-1): Ui, Vi = map(int, input().split()) adj_dict[Ui-1].append(Vi-1) adj_dict[Vi-1].append(Ui-1) memo = [[-1, -1] for _ in range(N)] ans = max(dfs(0, None, 0), dfs(0, None, 1)) print(ans)