N=int(input()) A,B=[],[] for i in range(N-1): x,y=map(int, input().split()) A.append(x) B.append(y) ans=10**12 a,b=sum(A),sum(B) ans=min(a,b)+1 for i in range(N-1): da,db=a-A[i],b-B[i] ans=min(ans,da+db+1) print(ans)