use strict; use warnings; my ($g, $c, $p) = split / /, <>; my $s = <>; chomp $s; my @sa = split //, $s; my $total = 0; for(my $i = 0; $i < $#sa + 1; $i++) { if($sa[$i] eq 'G') { if($p > 0) { $total += 3; $p--; } elsif($g > 0) { $total++; $g--; } else { $c--; } } elsif($sa[$i] eq 'C') { if($g > 0) { $total += 3; $g--; } elsif($c > 0) { $total++; $c--; } else { $p--; } } else { if($c > 0) { $total += 3; $c--; } elsif($p > 0) { $total++; $p--; } else { $g--; } } } print "$total\n"; exit;