A=[] i=0 Q=0 l=0 r=0 s=0 n,q=map(int,input().split()) for i in range(0,n,1): A.append(0) a=list(map(int,A)) for Q in range(0,q,1): l,r=map(int,input().split()) a[l:r]+=1 print(sum([p%2 != 0 for p in a]))