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