G,C,P = map(int,raw_input().split(' '))#GCP S = raw_input() count = 0 for c in S: if c == 'G': if P > 0: P-=1 count += 3 elif G > 0: G -=1 count += 1 else: C-=1 if c == 'C': if G > 0: G-=1 count += 3 elif C > 0: C -=1 count += 1 else: P-=1 if c == 'P': if C > 0: C-=1 count += 3 elif P > 0: P -=1 count += 1 else: G-=1 print count