class CountUpTrees attr_reader :s def initialize(s: "") @s = s end def cause begin @s = gets.chomp rescue end end def countuptrees(target, str) str_hash = {} str.split("").uniq.each do |c| str_hash[c] = str.count(c) end cnt_ary = str_hash.each.map do |c, cnt| target.count(c) / cnt end cnt_ary.min end def result puts countuptrees(@s, "tree") end def run cause result end end if $0 == __FILE__ CountUpTrees.new.run end