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 G >0 and G >= C and G >= P: G -= 1 elif C >0 and C >= P and C >= G: C -= 1 elif P > 0 and P >= G and P >= C: P-=1 print count