You can use two variable for a counter and a "System > for each" loop, and check every tile on your layout that is blue or red (for example you can check the current animationFrame). Or if the red tile and the blue tiles are different object/sprite, you can use two "for each" loop to count each object type.