import sys input = sys.stdin.readline N, Q = map(int, input().split()) table = [0] * N sm = 0 for _ in range(Q): l, r = map(int, input().split()) sm -= sum(table[l - 1: r]) for i in range(l - 1, r): table[i] ^= 1 sm += sum(table[l - 1: r]) print(sm)