lyj1150428217 @ 2022-08-15 15:42:37
if name == 'main': whole = input().split(' ')
lis = []
for i in range(int(whole[1])):
lis.append(input().split(' '))
tree = []
for i in range(int(whole[0])+1):
tree.append(i)
for li in lis:
for l in range(int(li[0]),int(li[1])+1):
if l in tree:
tree.remove(l)
else:
continue
print(len(tree))