defmodule Main do def main do [g, c, p] = li() m = input() |> String.codepoints |> Enum.frequencies [bg, bc, bp] = for x <- ["G", "C", "P"], do: Map.get(m, x, 0) ans = f(g, c, p, bg, bc, bp) IO.puts ans end def f(ag, ac, ap, bg, bc, bp) do g = min(ag, bc) c = min(ac, bp) p = min(ap, bg) if g+c+p == 0 do min(ag, bg) + min(ac, bc) + min(ap, bp) else 3 * (g + c + p) + f(ag-g, ac-c, ap-p, bg-p, bc-g, bp-c) end end def input, do: IO.read(:line) |> String.trim def ii, do: input() |> String.to_integer def li, do: input() |> String.split |> Enum.map(&String.to_integer/1) end