from functools import lru_cache def main(): N, Q = map(int, input().split()) lamps = set() for _ in range(Q): L, R = map(int, input().split()) for number in range(L, R+1): if number in lamps: lamps.discard(number) else: lamps.add(number) print(len(lamps)) if __name__ == "__main__": main()