from collections import deque N = int( input()) E = [ [] for _ in range(N)] for _ in range(N-1): a, b = map( int, input().split()) a, b = a-1, b-1 E[a].append(b) E[b].append(a) s = 0 V = [-1]*N V[s] = 0 d = deque() for t in E[s]: d.append(t) V[t] = 1 while d: t = d.popleft() l = V[t] for u in E[t]: if V[u] == -1: V[u] = l+1 s = V.index( max(V)) V = [-1]*N V[s] = 0 d = deque() for t in E[s]: d.append(t) V[t] = 1 while d: t = d.popleft() l = V[t] for u in E[t]: if V[u] == -1: V[u] = l+1 m = max(V) g = V.index(m) c = g ans = 0 Z = [0]*N Z[g] = 1 for i in range(m, 0, -1): for t in E[c]: if Z[t] == 1: continue if V[t] == i-1: c = t else: ans += 1 Z[t] = 1 print(ans)