class String
    def contract!
        0 while gsub!(/\+\-|\-\+/, "")
        0 while gsub!(/\+([A-Z])/) { (?A.ord + ($1.ord - ?A.ord + 1) % 26).chr }
        0 while gsub!(/\-([A-Z])/) { (?A.ord + ($1.ord - ?A.ord + 25) % 26).chr }
        0 while gsub!(/\[([^\[\]]+?)\]/) { $1.scan(/[-+]*[A-Z?]/).reverse.join }
    end
end

loop do
    s = gets.chomp
    break if s == ?.
    s.contract!

    k = s.count(??)
    if k == 0
        puts s
    else
        e = s.dup
        puts e.gsub(/([\-\+]*)\?/, ?A)
    end
end