from collections import deque, defaultdict def tree_diameter(n: int, adj: defaultdict) -> tuple[int, int, int]: def bfs(start): q = deque([start]) dists = [-1] * n dists[start] = 0 while q: v = q.popleft() for to in adj[v]: if dists[to] != -1: continue dists[to] = dists[v] + 1 q.append(to) return max((d, i) for i, d in enumerate(dists)) _, a = bfs(0) diam, b = bfs(a) return a, b, diam N = int(input()) adj = defaultdict(list) degs = [0] * N for _ in range(N-1): a, b = map(lambda x: int(x)-1, input().split()) adj[a].append(b) adj[b].append(a) degs[a] += 1 degs[b] += 1 u, v, _ = tree_diameter(N, adj) # 頂点 u, v 以外の次数 1 の頂点を取り除く q = deque() for i in range(N): if i == u or i == v: continue if degs[i] == 1: q.append(i) ans = 0 while q: v = q.popleft() ans += 1 degs[v] -= 1 for to in adj[v]: degs[to] -= 1 if degs[to] == 1: q.append(to) print(ans)