Directly count the number of memory instructions.