from sys import setrecursionlimit setrecursionlimit(10**6) def dfs1(pos): ret = 1 for nxt in G[pos]: ret += dfs1(nxt) Dist[pos] = ret return ret def dfs2(cnt, pos): global ans if len(G[pos]) == 0: return if len(G[pos]) == 1: dfs2(cnt+1, G[pos][0]) return D = 2 + cnt K = [] for nxt in G[pos]: K.append((Dist[nxt], nxt)) K.sort(reverse=True) N = K[:D] M = K[D:] for d,n in M: ans -= d cnt = max(0, cnt-(len(N)-2)) for d,n in N: dfs2(cnt, n) return N = int(input()) G = [[] for _ in range(N)] for _ in range(N-1): x,y = map(int,input().split()) x -= 1 y -= 1 G[x].append(y) Dist = [-1] * N dfs1(0) ans = N dfs2(0, 0) print(ans)