#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,n) for(long (i)=0;(i)<(n);(i)++) #define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++) #define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--) #define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--) #define MOD 1000000007 #define PI acos(-1.0) #define DEBUG(C) cout< #define PLL pair #define ALL(a) (a).begin(),(a).end() #define SORT(a) sort((a).begin(),(a).end()) #define RSORT(a) sort((a).begin(),(a).end(),greater()) typedef long long LL; typedef unsigned long long ULL; using namespace std; int main(void){ map mp; int jan[3]; REP(i,3) cin>>jan[i]; char h[3]={'G','C','P'};REP(i,3) mp[h[i]]=0; string s; cin>>s; REP(i,s.size()) mp[s[i]]++; int w=0,l=0,ans=0; REP(i,3){ int ww=min(mp[h[(i+1)%3]],jan[i]); if(ww==mp[h[(i+1)%3]]){ mp[h[(i+1)%3]]=0; jan[i]-=ww; }else{ jan[i]=0; mp[h[(i+1)%3]]-=ww; } w+=ww; //DEBUG(ww); } REP(i,3){ int num=min(mp[h[i]],jan[i]); if(num==mp[h[i]]){ mp[h[i]]=0; jan[i]-=num; }else{ jan[i]=0; mp[h[i]]-=num; } ans+=num; //DEBUG(num); } ans+=w*3; cout<