import Data.Char strToNum' :: String -> Integer strToNum' [] = 0 strToNum' (x:xs) | x == '4' = 7 + 10 * strToNum' xs | x == '7' = 4 + 10 * strToNum' xs | otherwise = fromIntegral (ord x - ord '0') + 10 * strToNum' xs strToNum = strToNum' . reverse main = do [a, b] <- getLine >>= return . words print $ maximum [strToNum a, strToNum b]