n,q=map(int,input().split()) anslist=[0]*n for _ in range(q): l,r=map(int,input().split()) for i in range(l-1,r): if anslist[i]==0: anslist[i]=1 elif anslist[i]==1: anslist[i]=0 print(anslist.count(1))