N, Q = map(int, input().split()) ans = [0] * (N + 1) for _ in range(Q): L, R = map(int, input().split()) for i in range(L, R + 1): ans[i] ^= 1 print(sum(ans))