N,Q = map(int,input().split()) switch = [0]*(N) ans = 0 for i in range(Q): L,R = map(int,input().split()) for j in range(L-1,R): if switch[j] == 0: switch[j] = 1 ans += 1 else: switch[j] = 0 ans -= 1 print(ans)