import numpy as np class sol(object): def __init__(self, N, tree): self.N = N self.tree = tree self.dp0 = np.array([0] * N, dtype=int) self.dp1 = np.array([0] * N, dtype=int) self.visit_cnt = [0] * N self.parent = np.array([-1] * N, dtype=int) def dns(self, cur): h = [] h.append(cur) childs = [[] for i in range(self.N)] while len(h) > 0: v = h.pop() self.visit_cnt[v] += 1 if len(self.tree[v]) == 0: self.dp0[v] = 1 self.dp1[v] = 0 elif self.visit_cnt[v] -1 < len(self.tree[v]): child = self.tree[v][self.visit_cnt[v] -1] if child != self.parent[v]: h.append(v) h.append(child) childs[v].append(child) self.parent[child] = v else: h.append(v) else: self.dp1[v] = sum([max(t) for t in zip(self.dp0[childs[v]], self.dp1[childs[v]])]) self.dp0[v] = 1 + sum([max(t[0] -1, t[1]) for t in zip(self.dp0[childs[v]], self.dp1[childs[v]])]) return def ans(self): self.dns(0) return max(self.dp0[0],self.dp1[0]) N=int(input()) tree = [[] for i in range(N)] for i in range(N -1): e = list(map(int, input().split())) tree[e[0] -1].append(e[1] -1) tree[e[1] -1].append(e[0] -1) print(sol(N, tree).ans())