S = gets.split("") count = 1 S.each{|i| s = i.ord - count while s < "A".ord s = "Z".ord + 1 - ("A".ord - s) end print s.chr count += 1 }