n,q = map(int, input().split()) def turnLamps(lamps, st, en): tmp_state = lamps for i in range(st, en): tmp_state[i] = swtichTurn(lamps[i]) return tmp_state def swtichTurn(state): return 1 if state == 0 else 0 lamps = [0 for i in range(n)] for i in range(q): st, en = map(int, input().split()) lamps = turnLamps(lamps, st -1, en) #print(*lamps) print(sum(lamps))