L,M = map(int,input().split()) road = [1]*(L+1) for _ in range(M): l,r = map(int,input().split()) for i in range(l,r+1): road[i]=0 print(sum(road))