# -*- coding: utf-8 -*- G, C, P = map(int, input().split()) S = input() g=c=p=0 for s in S: if s=='G': g += 1 elif s=='C': c += 1 else: p += 1 score = 0 # G,C,Pをまず勝てる方向で費やす score += 3*(min(G,c)+min(C,p)+min(P,g)) temp_G = G temp_C = C temp_P = P G = max(0, G-c) C = max(0, C-p) P = max(0, P-g) g = max(0, g-temp_P) c = max(0, c-temp_G) p = max(0, p-temp_C) # 残りは出来る限りあいこの方向で費やす score += min(G,g)+min(C,c)+min(P,p) print(score)