how to detect that 3 cube in the box are from the same tag

I use 3 empty box, i want to make puzzle game
Drag cube to match colors

3 Blue = Blue
3 Red = Red
3 Green = Green

The cube fit to any box no problem, just each box must have only a color from one type to win .

I have been working on it 3 weeks and nothing work

if you use Box Collider on boxes ,then you can use this in box script.

private void OnCollisionEnter(Collision collision)
if (collision.gameObject.tag == (“your cube”)) // checking if cube has tag you want
// what should happen