How can I get a cell to change its value based on another cell’s color?

I have three colors in column F: green, grey and red. What I want is for column G to display a number (1, 2, 3) depending on the color value of F.

Is there a way to do this?