import sys input = sys.stdin.readline n=int(input()) g = [[] for _ in range(n)] for i in range(n-1): u, v = map(int, input().split()) u, v = u-1, v-1 g[u].append(v) g[v].append(u) # topological順序の計算 s = [] s.append(0) parent = [-1]*n order = [] while s: x = s.pop() order.append(x) for nx in g[x]: if nx == parent[x]: continue parent[nx] = x s.append(nx) #print(order) order.reverse() dp0 = [0]*n dp1 = [0]*n for v in order: p = parent[v] dp1[v] += 1 if p != -1: dp0[p] += max(dp0[v], dp1[v]) dp1[p] += max(dp0[v], dp1[v]-1) #print(dp0) #print(dp1) print(max(dp0[0], dp1[0]))