N,Q = map(int,input().split()) switch = ['0']*(N+1) for i in range(Q): L,R = map(int,input().split()) for j in range(L-1,R+1): if switch[j] == '0' and L <= j and j <= R: switch[j] = '1' elif switch[j] == '1' and L <= j and j <= R: switch[j] = '0' print(switch.count('1'))