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