import Control.Applicative ((<$>)) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Data.List import Data.Char (isSpace) main :: IO () main = do solve <$> getl (readil B.readInt) >>= print fizzbuzz :: Int -> Int fizzbuzz x | x `mod` 15 == 0 = 8 | x `mod` 3 == 0 = 4 | x `mod` 5 == 0 = 4 | otherwise = (length . show) x solve :: [Int] -> Int solve = sum . map fizzbuzz getl :: (ByteString -> a) -> IO a getl f = f <$> B.getLine readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a] readil f = unfoldr g where g s = do (n, s') <- f s return (n, B.dropWhile isSpace s')