ml=list(map(int,input().split()))
ml[0]=ml[0]+1
bl=[]
for i in range(ml[1]):
tl=list(map(int,input().split()))
bl.append(tl)
list=[]
for i in range(ml[0]):
list.append(1)
for i in bl:
list[i[0]]=0
for j in range(i[1]-i[0]):
list[j+i[0]+1]=0
t=0
for i in range(len(list)):
if list[i]==1:
t+=1
print(t)
/**************************************************************
Problem: 1470
User: admin
Language: Python
Result: Accepted
Time:914 ms
Memory:34616 kb
****************************************************************/