n ,m=map(int,input().strip().split()) #n:商品类数;m:操作个数
op = [] # 操作列表
thing= [0]*(n+1)# 物品列表
for i in range(m): #输入操作列表并标记有货物的
l,r = map(int,input().strip().split())
op.append([l,r])
for i in range(l,r+1):
thing[i]+=1
res=0
for i in range(1,n+1):
if thing[i]==0:
res+=1
for i in range(m):
l=op[i][0]
r=op[i][1]
temp=res
for j in range(l,r+1):
thing[j]-=1
if thing[j]==0:
temp+=1
thing[j]+=1
print(temp)