main = getLine >>= putStrLn . w47 . words w47 [a,b] | la > lb = a | la < lb = b | p47 a b = max a b | otherwise = min a b where p47 x y = null $ dropWhile (\p -> p/=('4','7') && p/=('7','4')) (zip x y) la = length a lb = length b