import Data.List  -- sortBy, group
import Data.Ord   -- comparing

mode = fst . head . sortBy (flip $ comparing snd) . freqList
maxLen =     head . sortBy (flip $ comparing length)

freqList = map valFrq . group . sort -- list of value-freq pairs
  where
    valFrq ls = (head ls, length ls)

main = do s <- getLine
          putStrLn . modeMaxLen . words $ s
  where
          modeMaxLen ls = (mode ls) ++ " " ++ (maxLen ls)