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