yuki = gets.chomp.split(' ').map {|i| i.to_i} s = gets.chomp aite = [s.scan('C').length, s.scan('P').length, s.scan('G').length] #p yuki #p s #p aite point = 0 (0...3).each do |i| if yuki[i] >= aite[i] point += 3 * aite[i] yuki[i] -= aite[i] aite[i] = 0 else point += 3 * yuki[i] yuki[i] = 0 aite[i] -= yuki[i] end end #puts point #p aite.unshift(aite.pop) #p aite (0...3).each do |i| point += yuki[i] end puts point