main = do
  [n, a, b, c, d] <- fmap (fmap read . words) getLine
  print $ f n a b c d

f n a b c d = min (g n a b) (g n c d)
g n amount price 
  | n `mod` amount == 0 = n `div` amount * price
  | otherwise = (n `div` amount + 1) * price
