#include #include #include int dp[301][301][301]; char S[310]; // i: p, j: o int battle(char c, char d){ if(c == 'G' && d == 'C' || c == 'C' && d == 'P' || c == 'P' && d == 'G'){ return 3; } if(c == d){return 1;} return 0; } int main(){ int G, C, P; scanf("%d %d %d", &G, &C, &P); scanf("%s", S); int L = strlen(S); std::fill(&dp[0][0][0], &dp[0][0][0]+301*301*301, -1001001001); dp[0][0][0] = 0; for(int i=0;i P){continue;} if(j+1 <= G){ dp[i+1][j+1][k] = std::max(dp[i+1][j+1][k], dp[i][j][k] + battle('G', S[i])); } if(k+1 <= C){ dp[i+1][j][k+1] = std::max(dp[i+1][j][k+1], dp[i][j][k] + battle('C', S[i])); } if(l+1 <= P){ dp[i+1][j][k] = std::max(dp[i+1][j][k], dp[i][j][k] + battle('P', S[i])); } } } } int res = 0; for(int j=0;j<=G;j++){ for(int k=0;k<=C;k++){ res = std::max(res, dp[L][j][k]); } } printf("%d\n", res); }