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