import Data.List

--zeros = listArray ('a', 'z') (repeat 0)

count :: String -> [(Char, Int)]
count = map (\cs -> (head cs, length cs)). group . sort

minCount :: [(Char, Int)] -> [(Char, Int)] -> [(Char, Int)]
minCount [] _ = []
minCount _ [] = []
minCount (hd1 : tl1) (hd2 : tl2)
  | fst hd1 == fst hd2 = (fst hd1, min (snd hd1) (snd hd2)) : minCount tl1 tl2
  | fst hd1 < fst hd2 = minCount tl1 (hd2 : tl2)
  | otherwise = minCount (hd1 : tl1) tl2

main = do
  (tail . lines) <$> getContents >>=
    putStrLn . concatMap (uncurry (flip replicate)) . foldl1 minCount . map count

