N, *AB = map(int, open(0).read().split()) A = sum(AB[::2]) B = sum(AB[1::2]) print(min(A, B) + 1)