g,c,p = map(int,input().split()) S = input() G = S.count('G') P = S.count('P') C = S.count('C') ans = 0 m = min(g,C) ans += m g -= m C -= m m = min(c,P) ans += m c -= m P -= m m = min(p,G) ans += m ans *= 3 p -= m G -= m m = min(p,P) ans += m p -= m P -= m m = min(c,C) ans += m c -= m C -= m m = min(g,G) ans += m g -= m G -= m print(ans)