import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int g1 = sc.nextInt(); int c1 = sc.nextInt(); int p1 = sc.nextInt(); String s = sc.next(); int g2 = 0; int c2 = 0; int p2 = 0; for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == 'G') { g2++; } else if(s.charAt(i) == 'C') { c2++; } else { p2++; } } int ans = 0; int s1 = Math.min(g2, p1); ans += (3 * s1); g2 -= s1; p1 -= s1; int s2 = Math.min(c2, g1); ans += (3 * s2); c2 -= s2; g1 -= s2; int s3 = Math.min(p2, c1); ans += (3 * s3); p2 -= s3; c1 -= s3; int t1 = Math.min(g2, g1); ans += t1; g2 -= t1; g1 -= t1; int t2 = Math.min(c2, c1); ans += t2; c2 -= t2; c1 -= t2; int t3 = Math.min(p2, p1); ans += t3; p2 -= t3; p1 -= t3; System.out.println(ans); } }