N = int(input()) lsA = [] lsB = [] for i in range(N-1): A,B = map(int,input().split()) lsA.append(A) lsB.append(B) sumA = sum(lsA) sumB = sum(lsB) ans = min(sumA,sumB) cnt = 0 for i in range(sumA+sumB,max(sumA,sumB)-1,-1): f = True lsA1 = lsA[:]+[i-sumA] lsB1 = lsB[:]+[i-sumB] for j in range(N): if lsA1[j] > i-lsB1[j]: f = False if f: cnt += 1 print(cnt)