import Control.Applicative ((<$>))

main :: IO ()
main = do
  [n, a, b, c, d] <- map read . words <$> getLine
  print $ solve n a b c d

solve :: Int -> Int -> Int -> Int -> Int -> Int
solve n a b c d = (solve' n a b) `min` (solve' n c d)

solve' :: Int -> Int -> Int -> Int
solve' n a b
  | r == 0
    = q * b
  | otherwise
    = (q + 1) * b
  where
    (q, r) = n `divMod` a
