n = int(input()) sma=0 smb=0 for i in range(n-1): a,b = list(map(int,input().split())) sma+=a smb+=b print(min(sma,smb)+1)