from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,copy,time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) N = inp() sA = sB = mA = mB = 0 for _ in range(N-1): A,B = inpl() sA += A sB += B mA = max(A,mA) mB = max(B,mB) if N == 2: print(1) else: print(min(sA,sB)+1)