import java.util.Scanner; public class Main_yukicoder161 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int g = sc.nextInt(); int c = sc.nextInt(); int p = sc.nextInt(); char[] s = sc.next().toCharArray(); int og = 0; int oc = 0; int op = 0; for (char ch : s) { if (ch == 'G') { og++; } else if (ch == 'C') { oc++; } else if (ch == 'P') { op++; } } int ret = 0; int tmp; tmp = Math.min(g, oc); g -= tmp; oc -= tmp; ret += 3 * tmp; tmp = Math.min(c, op); c -= tmp; op -= tmp; ret += 3 * tmp; tmp = Math.min(p, og); p -= tmp; og -= tmp; ret += 3 * tmp; tmp = Math.min(g, og); g -= tmp; og -= tmp; ret += tmp; tmp = Math.min(c, oc); c -= tmp; oc -= tmp; ret += tmp; tmp = Math.min(p, op); p -= tmp; op -= tmp; ret += tmp; System.out.println(ret); sc.close(); } }