N=int(input()) S=[tuple(map(int,input().split())) for i in range(N-1)] ANS=1 for x,y in S: ANS+=y print(ANS)