from collections import Counter g,c,p = map(int, raw_input().split()) ct = Counter(raw_input()) x = min(g, ct['C']) g = max(0, g-x) ct['C'] = max(0, ct['C']-x) y = min(c, ct['P']) c = max(0, c-y) ct['P'] = max(0, ct['P']-y) z = min(p, ct['G']) p = max(0, p-z) ct['G'] = max(0, ct['G']-z) w = max(g, ct['G']) w += max(c, ct['C']) w += max(p, ct['P']) print (x+y+z)*3 + w