using System; using System.Linq; namespace Seigen_Janken { class Program { static void Main(string[] args) { Sol sol = new Sol(); sol.Solve(); } } class Sol { public void Solve() { int GN = Math.Min(G, eC); int CN = Math.Min(C, eP); int PN = Math.Min(P, eG); G -= GN; eC -= GN; C -= CN; eP -= CN; P -= PN; eG -= PN; int GDraw = Math.Min(G, eG); int CDraw = Math.Min(C, eC); int PDraw = Math.Min(P, eP); int aiko = GDraw + CDraw + PDraw; int ans = 3 * (GN + CN + PN) + aiko; Console.WriteLine(ans); } int G, C, P; string S; int eG, eC, eP; public Sol() { int[] t = ria(); G = t[0]; C = t[1]; P = t[2]; S = rs(); eG = CountChar(S, 'G'); eC = CountChar(S, 'C'); eP = CountChar(S, 'P'); } // 文字列s中に含まれるcの数を返す static int CountChar(string s, char c) { return s.Length - s.Replace(c.ToString(), "").Length; } public override string ToString() { return (string.Format("G:{0}, C:{1}, P{2}\n", G, C, P) + S + string.Format("\neG:{0}, eC:{1}, eP{2}", eG, eC, eP)); } static String rs() { return Console.ReadLine(); } static int ri() { return int.Parse(Console.ReadLine()); } static long rl() { return long.Parse(Console.ReadLine()); } static double rd() { return double.Parse(Console.ReadLine()); } static String[] rsa() { return Console.ReadLine().Split(' '); } static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); } static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); } static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); } } }