def main(): import sys input = sys.stdin.buffer.readline n, q = map(int, input().split()) lis = [0] * n for _ in range(q): l, r = map(int, input().split()) for i in range(l - 1, r): lis[i] ^= 1 print(sum(lis)) if __name__ == '__main__': main()