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