Save ids to memory and count.