import Data.Char main = getLine >>= putStrLn . solve solve :: String -> String solve xs = fst $ foldr ff ([], m) xs where m = length xs ff x (acc, n) | ord x - n < ord 'A' = ((chr $ ord 'Z' - ord x + n - 1 + ord 'A') : acc, n - 1) | otherwise = ((chr $ ord x - n) : acc, n - 1)