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