cal=[[0 for i in range(367)] for i in range(1000)]
dict={}
for i in range(2,14):
dict[i]=0
work=[]
n=int(input())
for i in range(n):
s,e=map(int, input().split())
work.append([s,e])
work.sort(key=lambda x:(x[0],-x[1]))
for w in work:
s,e=w[0],w[1]
count=0
for j in range(s,e+1):
while cal[count][j]==1:
count+=1
for j in range(s,e+1):
cal[count][j]=1
answer=0
ga,se=0,0
for j in range(367):
flag=True
count=0
for i in range(1000):
if cal[i][j]==1:
flag=False
count=i
se=max(count,se)
if flag:
answer+=ga*(se+1)
ga,se=0,0
else:
ga+=1
print(answer)