--- /dev/null
+import qualified Data.Map as M
+
+main :: IO ()
+main = do
+ input <- getContents
+ let ids = lines input
+ let count_twos = countN 2 ids
+ let count_threes = countN 3 ids
+ print (count_twos * count_threes)
+ putStrLn . abc $ ids
+
+countN :: Int -> [String] -> Int
+countN check_count = sum . map (go check_count)
+ where go :: Int -> String -> Int
+ go cc test = if any (== cc) . M.elems . countChar $ test
+ then 1
+ else 0
+
+countChar :: String -> M.Map Char Int
+countChar = foldl go M.empty
+ where go :: M.Map Char Int -> Char -> M.Map Char Int
+ go chmap char = M.insert char ((M.findWithDefault 0 char chmap) + 1) chmap
+
+abc :: [String] -> String
+abc (i:is)
+ | null test = abc is
+ | otherwise = head test
+ where cor_len = (length i) - 1
+ test = filter (\s -> (length s) == cor_len) . map (diff i) $ is
+
+diff :: Eq a => [a] -> [a] -> [a]
+diff [] [] = []
+diff (a:as) (b:bs)
+ | a == b = (a : diff as bs)
+ | otherwise = diff as bs