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