local n, q = io.read("*n", "*n") local t = {} for i = 1, n do t[i] = 0 end local c = 0 for iq = 1, q do local l, r = io.read("*n", "*n") for i = l, r do if t[i] == 1 then c = c - 1 else c = c + 1 end t[i] = 1 - t[i] end print(c) end