import sys #sys.setrecursionlimit(n) import heapq import re import bisect import random import math import itertools from collections import defaultdict, deque from copy import deepcopy from decimal import * g,c,p = list(map(int, input().split())) e = deque((map(str, input()))) eg = e.count('G') ec = e.count('C') ep = e.count('P') ans = 0 for i in e: if eg > 0 and p > 0: eg -= 1 p -= 1 ans += 3 elif ec > 0 and g > 0: ec -= 1 g -= 1 ans += 3 elif ep > 0 and c > 0: ep -= 1 c -= 1 ans += 3 elif eg > 0 and g > 0: eg -= 1 g -= 1 ans += 1 elif ec > 0 and c > 0: ec -= 1 c -= 1 ans += 1 elif ep > 0 and p > 0: ep -= 1 p -= 1 ans += 1 else: break print(ans)