N=int(input()) A=B=0 for _ in range(2,N+1): a,b=map(int,input().split()) A+=a B+=b X=0 for alpha in range(B+1): beta=alpha+A-B if 0<=beta<=A: X+=1 print(X)