import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; public class Main { public static final int C = 1000000007; static final int CY = 1000000000; //static boolean MAP[][]; static int N; static int X; static double P; static String S; static int M; static int MAX = -1; //static int tic[][]; //static String S[]; static long A[]; static double W[]; //static int max; static long DP[]; static int ST[][]; static ConcurrentSkipListSet TS; static ArrayList AL; public static void main(String[] args) { StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int[] gcp = new int[3]; gcp[0] = sc.nextInt(); gcp[1] = sc.nextInt(); gcp[2] = sc.nextInt(); String str = sc.next(); int[] fgcp = new int[3]; for (int i=0; i < str.length(); i++) { char c = str.charAt(i); if (c == 'G') fgcp[0]++; if (c == 'C') fgcp[1]++; if (c == 'P') fgcp[2]++; } long ans = 0; for (int i=0; i < 3; i++) { int f = i+1 == 3? 0:i+1; int num = Math.min(gcp[i], fgcp[f]); gcp[i] -= num; fgcp[f] -= num; ans += num * 3; } for (int i=0; i < 3; i++) { // int f = i+1 == 3? 0:i+1; int num = Math.min(gcp[i], fgcp[i]); gcp[i] -= num; fgcp[i] -= num; ans += num * 1; } System.out.println(ans); } }