import Control.Applicative main = do vs <- map read . words <$> getLine let f [] n = if n == 0 then 0 else 10000 f ys@(x:xs) n | x <= n = min (f ys (n-x) + 1) (f xs n) | otherwise = f xs n mn = minimum [sum $ map (f [c,b,a]) vs | a <- [1..30], b <- [a..30], c <- [b..30]] in print mn