G, C, P = gets.split.map(&:to_i) S = gets.chomp g, c, p = ["G", "C", "P"].map {|s| S.count(s)} def f(a, b) return [a - b, 0].max end ans = 3 * [[G, c], [C, p], [P, g]].map(&:min).inject(:+) + [[f(G, c), f(g, P)], [f(C, p), f(c, G)], [f(P, g), f(p, C)]].map(&:min).inject(:+) puts ans