n,q=map(int,input().split()) a=[0]*n for i in range(q): l,r=map(int,input().split()) l-=1 r-=1 for j in range(l,r+1): a[j]^=1 print(sum(a))