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