N = int(input()) A, B = 0, 0 for i in range(N - 1): a, b = map(int, input().split()) A += a B += b print(min(A, B) + 1)