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