import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.Map; import java.io.BufferedReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class HelloWorld { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskD solver = new TaskD(); solver.solve(1, in, out); out.close(); } static class TaskD { public void solve(int testNumber, InputReader in, PrintWriter out) { int gcp[] = new int[3]; for(int i=0; i<3; i++){ gcp[i] = in.nextInt(); } String S = in.next(); char s[] = S.toCharArray(); int fgcp[] = new int[3]; for(char c:s){ if(c=='G') fgcp[0]++; if(c=='C') fgcp[1]++; if(c=='P') fgcp[2]++; } int p=0; for(int i=0; i<3; i++){ int num = Math.min(gcp[i],fgcp[(i+1)%3]); gcp[i] -= num; fgcp[(i+1)%3] -= num; p += 3*num; } for(int i=0; i<3; i++){ int num = Math.min(gcp[i],fgcp[i]); gcp[i] -= num; fgcp[i] -= num; p += num; } out.println(p); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }