N,Q=map(int,input().split()) dp=[0]*(N+1) for _ in range(Q): l,r=map(int,input().split()) dp[l-1]+=1 dp[r]+=-1 ans=0 for i in range(N): ans+=dp[i]%2 dp[i+1]+=dp[i]