A=gets.split.map &:to_i gets B=%w(G C P).map{|c|$_.count(c)} s=0 (0..2).map{|i|t=[A[i],B[i-2]].min;s+=t*3;B[i-2]-=t;A[i]-t}.zip(B).map{|x|s+=x.min} p s