def calc(a, b, i, j, p) cnt = [a[i], b[j]].min a[i] -= cnt b[j] -= cnt return p * cnt end G, C, P = gets.split.map(&:to_i) S = gets a = [G, C, P] b = S.count("G"), S.count("C"), S.count("P") point = 0 point += calc(a, b, 0, 1, 3) point += calc(a, b, 1, 2, 3) point += calc(a, b, 2, 0, 3) point += calc(a, b, 0, 0, 1) point += calc(a, b, 1, 1, 1) point += calc(a, b, 2, 2, 1) puts point