n,q=map(int,input().split()) cnt=0 f=[0]*(n+10) for _ in range(p): l,r=map(int,input().split()) for i in range(l,r+1): cnt-=f[i] f[i]^=1 cnt+=f[i] print(cnt)