package main import ( "bufio" "os" "strconv" "fmt" ) var s = bufio.NewScanner(os.Stdin) func next() string { s.Split(bufio.ScanWords) s.Scan() return s.Text() } func nextInt() int { i, e := strconv.Atoi(next()) if e != nil { panic(e) } return i } func nextLong() int64 { i, e := strconv.ParseInt(next(), 10, 64) if e != nil { panic(e) } return i } func main() { D := [3]int{} D[0] = nextInt() D[1] = nextInt() D[2] = nextInt() S := next() checked := make([]bool, len(S)) point := 0 for k := -1; k < 2; k++ { for i := 0; i < len(S); i++ { var P = 0 switch { case checked[i]: break case S[i] == 'G': P = 0 case S[i] == 'C': P = 1 case S[i] == 'P': P = 2 } p := (P + k + 3) % 3 if D[p] > 0 { D[p]-=1 if k == -1 { point+=3 checked[i] = true }else if k == 0 { point+=1 checked[i] = true } } } } fmt.Println(point) }