#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int A[3]; rep(i,3) cin >> A[i]; int B[3] = {}; string S; cin >> S; for(char c : S) { if(c == 'G') B[0]++; if(c == 'C') B[1]++; if(c == 'P') B[2]++; } int ans = 0; rep(i,3) { int k = min(A[i], B[(i + 1) % 3]); ans += k * 3; A[i] -= k; B[(i + 1) % 3] -= k; } rep(i,3) ans += min(A[i], B[i]); cout << ans << endl; }