import Data.Char

-- lower case to integer
let2intLow :: Char -> Int
let2intLow c = ord c - ord 'a'

-- upper case to integer
let2intUpp :: Char -> Int
let2intUpp c = ord c - ord 'A'

-- integer to lower case
int2letLow :: Int -> Char
int2letLow n = chr (ord 'a' + n)

-- integer to upper case
int2letUpp :: Int -> Char
int2letUpp n = chr (ord 'A' + n)

-- shift a character c by slots to the right
shift :: Int -> Char -> Char
shift n c | isLower c = int2letLow ((let2intLow c + n) `mod` 26)
		  | isUpper c = int2letUpp ((let2intUpp c + n) `mod` 26)
		  | otherwise = c

-- top-level string encoding function
encode :: Int -> String -> String
encode n xs = [shift n x | x <- xs]

-- table of frequencies of letters 'a'..'z'
table :: [Float]
table = [8.2,1.2,2.8,4.3,12.7,2.2,2.0,6.1,7.0,0.2,0.8,4.0,2.4,6.7,7.5,1.9,0.1,6.0,6.3,9.1,2.8,1.0,2.4,0.2,2.0,0.1]

percent :: Int -> Int -> Float
percent n m = (fromIntegral n / fromIntegral m) * 100

-- compute frequencies of letters 'a'..'z' in a given string
alphas :: String -> Int
alphas xs = length [x | x <- xs, isAlpha x]

freqs :: String -> [Float]
freqs xs = [percent (count x xs') n | x <- ['a'..'z']]
			where 
			xs' = map toLower xs
			n = alphas xs

-- chi-square function for computing distance between 2 frequency lists
chisqr :: [Float] -> [Float] -> Float
chisqr xs ys = sum [((x - y)^2) / y | (x,y) <- zip xs ys]

-- rotate a list by n slots to the left; take, drop, are Prelude functions
rotate :: Int -> [a] -> [a]
rotate n xs = drop n xs ++ take n xs

-- count the number of occurrences of c in cs
count :: Char -> String -> Int
count x xs = length [x' | x' <- xs, x == x']

-- find list of positions of x in the list xs
positions :: Eq a => a -> [a] -> [Int]
positions x xs = [i | (x',i) <- zip xs [0..n], x == x']
				where n = length xs - 1

-- top-level decoding function
crack :: String -> String
crack xs = encode (-factor) xs
			where 
			factor = head (positions (minimum chitab) chitab)
			chitab = [chisqr (rotate n table') table | n <- [0..25]]
			table' = freqs xs


main = do
	line <- getLine
	if null line
		then return ()
	else do
		putStrLn $ crack line
		main