n, q = map(int, input().split()) a = [0] * n ans = 0 for _ in range(q): l, r = map(int, input().split()) for j in range(l - 1, r): a[j] ^= 1 if a[j]: ans += 1 else: ans -= 1 print(ans)