from sys import stdin def main(inp, inps): N, Q = map(int, inp().split()) L, R = list(zip(*map(lambda x: list(map(int, x.split())), inps()))) now_bit = 0 for l, r in zip(L, R): now_bit ^= 2**r - 2**(l-1) print(sum(map(int, list(bin(now_bit)[2:])))) main(stdin.readline, stdin.readlines)