using static System.Math; using System; public class Hello { public static int g, c, p, g2, c2, p2; static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); g = int.Parse(line[0]); c = int.Parse(line[1]); p = int.Parse(line[2]); var gcp = g + c + p; var s = Console.ReadLine().Trim(); g2 = gcp - s.Replace("G", "").Length; c2 = gcp - s.Replace("C", "").Length; p2 = gcp - g2 - c2; getAns(); } static void getAns() { var ans = 0; var gwin = Min(g, c2); ans += gwin * 3; g -= gwin; c2 -= gwin; var cwin = Min(c, p2); ans += cwin * 3; c -= cwin; p2 -= cwin; var pwin = Min(p, g2); ans += pwin * 3; p -= pwin; g2 -= pwin; ; var gd = Min(g, g2); ans += gd; var cd = Min(c, c2); ans += cd; var pd = Min(p, p2); ans += pd; Console.WriteLine(ans); } }