#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair pi; typedef pair, ll > pii; vector vec; vector vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main() { ll G, C, P; cin >> G >> C >> P; string S; cin >> S; map mp; for(ll i = 0; i < S.length(); i++){ mp[S[i]]++; } ll ans = 0; //勝てますか? //グー ans += 3 * min(mp['G'], P); P -= min(mp['G'], P); mp['G'] -= min(mp['G'], P); //チョキ ans += 3 * min(mp['C'], G); G -= min(mp['C'], G); mp['C'] -= min(mp['C'], P); //パー ans += 3 * min(mp['P'], C); C -= min(mp['P'], C); mp['P'] -= min(mp['P'], P); //アイコにできますか //グー ans += min(mp['G'], G); G -= min(mp['G'], G); mp['G'] -= min(mp['G'], G); //チョキ ans += min(mp['C'], C); C -= min(mp['C'], C); mp['C'] -= min(mp['C'], C); //パー ans += min(mp['P'], P); P -= min(mp['P'], P); mp['P'] -= min(mp['P'], P); cout << ans << endl; }