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