N = int(input()) if N == 2: print(1) exit() A_sum, B_sum = 0, 0 for i in range(N - 1): A, B = map(int,input().split()) A_sum += A B_sum += B print(min(A_sum, B_sum) + 1)