G,C,P = map(int,raw_input().split(' '))#GCP S = raw_input() count = 0 win = 0 drow = 0 g,c,p = 0,0,0 for s in S: if s == 'G': g += 1 if s == 'C': c += 1 if s == 'P': p += 1 count += min(G,c)*3 count += min(C,p)*3 count += min(P,g)*3 G -= min(G,c) c -= min(G,c) C -= min(C,p) p -= min(C,p) P -= min(P,g) g -= min(P,g) count += min(G,g) count += min(C,c) count += min(P,p) print count