package main import ( "fmt" ) func min(x, y int) int { if y < x { return y } return x } func main() { var G, C, P, oG, oC, oP, gWin, cWin, pWin int var S string fmt.Scan(&G, &C, &P, &S) for _, r := range S { switch r { case 'G': oG++ case 'C': oC++ case 'P': oP++ } } gWin, cWin, pWin = min(G, oC), min(C, oP), min(P, oG) G -= gWin oC -= gWin C -= cWin oP -= cWin P -= pWin oG -= pWin res := 3*(gWin+cWin+pWin) + min(G, oG) + min(C, oC) + min(P, oP) fmt.Println(res) }