str = gets.chomp str.gsub!("(^^*)","l").gsub!("(*^^)","r") puts "#{str.count("l")} #{str.count("r")}"