solve :: [Int] -> [Int] solve [] = [] solve (x:xs) = y : solve xs where y = if (x `mod` 15) == 0 then 8 else if (x `mod` 3 == 0) || (x `mod` 5 == 0) then 4 else length $ show x main = interact $ show . sum . solve . map read . words