import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static int score(char y, char f){ if(y == f){ return 1;} else if(y == 'G' && f == 'C' || y == 'C' && f == 'P' || y == 'P' && f == 'G'){ return 3; } else { return 0; } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int G = sc.nextInt(); final int C = sc.nextInt(); final int P = sc.nextInt(); final char[] S = sc.next().toCharArray(); int[][][] DP = new int[G + 1][C + 1][P + 1]; for(int i = 0; i <= G; i++){ for(int j = 0; j <= C; j++){ for(int k = 0; k <= P; k++){ final int sum = i + j + k; if(i != G){ DP[i + 1][j][k] = Math.max(DP[i + 1][j][k], DP[i][j][k] + score('G', S[sum])); } if(j != C){ DP[i][j + 1][k] = Math.max(DP[i][j + 1][k], DP[i][j][k] + score('C', S[sum])); } if(k != P){ DP[i][j][k + 1] = Math.max(DP[i][j][k + 1], DP[i][j][k] + score('P', S[sum])); } } } } System.out.println(DP[G][C][P]); } }