I=lambda:list(map(int,input().split())) n,m=I() q=sorted([I()for i in range(m)],key=lambda x:x[1]) r=0 d=2*n-2 for a,b in q: if a>=r:r=b;d-=1 print(d)