def janken(G, C, P, S): p = 0 for s in S: if s == 'G': if P > 0: P -= 1 p += 3 elif G > 0: G -= 1 p += 1 elif s == 'C': if G > 0: G -= 1 p += 3 elif C > 0: C -= 1 p += 1 elif s == 'P': if C > 0: C -= 1 p += 3 elif P > 0: P -= 1 p += 1 return p def main(): G, C, P = map(int, input().split()) S = input() print(janken(G, C, P, S)) if __name__ == '__main__': main()