Count[Tuples[{r,g,y},5],{___,g,g,___}]