import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) G = [[] for _ in range(N)] for _ in range(N - 1): a, b = map(int, input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append(a) topo = [] par = [-1] * N q = [0] while q: s = q.pop() topo.append(s) for t in G[s]: if t == par[s]: continue G[t].remove(s) par[t] = s q.append(t) X = [0] * N # 根付き木iの根が残ってるときの最大 Y = [0] * N # 根を消した時の最大 for s in reversed(topo): if not G[s]: X[s] = 1 continue sumY = 0 sumXY = 0 for t in G[s]: sumY += Y[t] sumXY += max(X[t], Y[t]) X[s] = max(sumY + 1, sumXY) Y[s] = sumXY print(max(X[0], Y[0]))