g,c,p = list(map(int, input().split())) hands=[c,g,p] s = input() ans=0 te="CGPCGP" for i in range(len(s)): draw = te.find(s[i]) win = (te.find(s[i])+1)%3 lose = (te.find(s[i])+2)%3 if hands[win] > 0: hands[win]-=1 ans+=3 elif hands[draw] > 0: hands[draw]-=1 ans+=1 else: hands[lose]-=1 print(ans)