G,C,P = map(int,raw_input().split())#GCP S = list(raw_input()) count = 0 g = S.count('G') c = S.count('C') p = S.count('P') count += min(G,c)*3 count += min(C,p)*3 count += min(P,g)*3 Gc = min(G,c) Cp = min(C,p) Pg = min(P,g) G -= Gc c -= Gc C -= Cp p -= Cp P -= Pg g -= Pg count += min(G,g) count += min(C,c) count += min(P,p) print count