$s = STDIN.gets $ans = 0 def f temp = 0 $s.scan(/phnom/).each do |t| temp += 1 end if $s.include?("phnom") then $s.gsub!(/phnom/, "penh") end if $s.include?("h") then temp += 1 $s.gsub!(/h/, "") $s.gsub!(/e/, "h") end # puts $s temp end $ans += f $ans += f $s.scan(/phn(?:om)+/).each do |t| $ans += t.length - 3 end if $s.include?("phnom") then $ans += 1 elsif $s.include?("h") then $ans += 1 end puts $ans