N = int(input()) A = [] B = [] for _ in range(N-1): a,b = map(int,input().split()) A.append(a) B.append(b) print(max(sum(A),sum(B))-abs(sum(A)-sum(B))+1)