L, M = map(int, input().split())
total = L + 1
move_set = set()
for m in range(M):
    l, r = map(int, input().split())
    move_set.update(range(l, r+1))
print(total - len(move_set))