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