import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) ta,tb=0,0 for i in range(n-1): a,b=map(int,input().split()) ta+=a tb+=b print(min(ta,tb)+1)