def Calc(m,n,sum): sum += min(m,n) m -= min(m,n) n -= min(m,n) return [m,n,sum] G,C,P = [int(x) for x in input().split(" ")] S = input() oG = S.count('G') oC = S.count('C') oP = S.count('P') res = 0 sum = 0 G,oC,sum = Calc(G,oC,sum) C,oP,sum = Calc(C,oP,sum) P,oG,sum = Calc(P,oG,sum) res += sum * 3 sum = 0 G,oG,sum = Calc(G,oG,sum) C,oC,sum = Calc(C,oC,sum) P,oP,sum = Calc(P,oP,sum) res += sum print(res)