G,C,P = map(int,raw_input().split(' '))#GCP S = raw_input() win = 0 drow = 0 b = [False for i in range(len(S))] for s in range(len(S)): if S[s] == 'G' and P > 0: win += 1 P -=1 b[i] = True if S[s] == 'C' and G > 0: win += 1 G -=1 b[i] = True if S[s] == 'P' and C > 0: win += 1 C -= 1 b[i] = True for i in range(len(S)): if b[i]: continue if S[i] == 'G' and G > 0: drow += 1 G -= 1 if S[i] == 'C' and C > 0: drow += 1 C -= 1 if S[i] == 'P' and P > 0: drow += 1 P -=1 count = win * 3 + drow print count