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