#include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template using V = vector; template using VV = V>; template using VVV = V>; template using VVVV = VV>; #define rep(i,n) for(ll i=0ll;i bool chmin(T& t, const U& u) { if (t > u){ t = u; return 1;} return 0; } template bool chmax(T& t, const U& u) { if (t < u){ t = u; return 1;} return 0; } void solve(){ V v(3); rep(i,3) cin >> v[i]; V w(3, 0); string s; cin >> s; for(auto c:s){ if(c == 'G') w[0]++; else if(c == 'C') w[1] ++; else w[2] ++; } ll ans = 0; rep(i, 3){ while(v[i] && w[(i+1)%3]){ v[i] --; w[(i+1)%3]--; ans += 3; } } rep(i, 3){ while(v[i] && w[i]){ v[i] --; w[i]--; ans += 1; } } cout << ans << endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t=1; // cin >> t; rep(i,t) solve(); }