g, c, p = map(int, input().split()) s = input() n = g + c + p ans = 0 for i in range(n): if s[i] == 'G': if p > 0: ans += 3 p -= 1 elif g > 0: ans += 1 g -= 1 else: c -= 1 elif s[i] == 'C': if g > 0: ans += 3 g -= 1 elif c > 0: ans += 1 c -= 1 else: p -= 1 else: if c > 0: ans += 3 c -= 1 elif p > 0: ans += 1 p -= 1 else: g -= 1 print(ans)