zchu @ 2023-04-29 14:23:28
l,m = map(int,input().split())
tree = l+1
region = []
for i in range(m) :
u,v = map(int,input().split())
region.append([u,v])
region.sort(reverse=False)
for i in range(m-1) :
if region[i][1]>region[i+1][0] :
region[i][1] = region[i+1][0]-1
for i in range(m) :
cut = region[i][1]-region[i][0]+1
tree = tree-cut
print(tree)