#include //const static double de_PI = 3.14159265358979323846; //const static int de_MOD = 1000000007; //const static int de_MAX = 999999999; //const static int de_MIN = -999999999; int main(void) { //std::ifstream in("123.txt"); std::cin.rdbuf(in.rdbuf()); int g1 = 0, c1 = 0, p1 = 0; int g2 = 0, c2 = 0, p2 = 0; std::string S; std::cin >> g1 >> c1 >> p1 >> S; g2 = std::count(S.begin(), S.end(), 'G'); c2 = std::count(S.begin(), S.end(), 'C'); p2 = S.length() - g2 - c2; int ans = 0; while (g1 != 0 && c2 != 0) { g1--; c2--; ans += 3; } while (c1 != 0 && p2 != 0) { c1--; p2--; ans += 3; } while (p1 != 0 && g2 != 0) { p1--; g2--; ans += 3; } while (g1 != 0 && g2 != 0) { g1--; g2--; ans++; } while (c1 != 0 && c2 != 0) { c1--; c2--; ans++; } while (p1 != 0 && p2 != 0) { p1--; p2--; ans++; } std::cout << ans << std::endl; }