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