max' :: [Integer] -> Integer max' (a : b : _) | length a' > length b' = a | length b' > length a' = b | otherwise = rmax $ zip a' b' where (a', b') = (show a, show b) rmax ((a'', b'') : ps) | a'' == '4' && b'' == '7' = a | a'' == '7' && b'' == '4' = b | a'' > b'' = a | b'' > a'' = b | otherwise = rmax ps main :: IO () main = print . max' . map read . words =<< getLine