count = int(input())
# print('\n')
# print(f'count: {count}')
collectRL = []
for _ in range(count):
collectRL.extend(list(map(int, input().split(" "))))
newCollect = collectRL
difference = []
first = []
for j in range(1, len(collectRL), 2):
# print(j)
difference.append(collectRL[j] - collectRL[j-1])
first.append(collectRL[j-1])
# print(difference)
newCollect.sort()
# print(newCollect)
test = [0] * newCollect[-1]
for i in range(count):
for j in range(difference[i]):
test[first[i] + j] = 1
# print(first)
result = 0
for n in range(len(test)):
if test[n] == 1:
result+=1
print(result)