input = gets.chomp puts input.reverse.gsub(/<|>/, '<' => '>', '>' => '<')