N=int(input()) G=[[] for i in range(N)] for i in range(N-1): a,b=map(int,input().split()) G[a-1].append(b-1) G[b-1].append(a-1) from collections import deque S=deque() dist=[-1]*N dist[0]=0 L=[0] S.append(0) while S: x=S.pop() for y in G[x]: if dist[y]==-1: dist[y]=dist[x]+1 S.append(y) L.append(y) L=L[::-1] dp=[[0]*2 for i in range(N)] h=[] for pos in L: score=0 l=[] n=len(G[pos]) for y in G[pos]: if dist[y]2 or pos==0: c+=l[w] dp[pos][1]=min(dp[pos][1],c) print(dp[0][1])