--import Control.Applicative ((<$>)) import Control.Monad (replicateM) import Prelude hiding (lcm) import Data.Char (isSpace) import Data.List (transpose, unfoldr) import qualified Data.ByteString.Char8 as BSC8 getLL :: (BSC8.ByteString -> [Integer]) -> IO [Integer] getLL f = f <$> BSC8.getLine readILL :: (BSC8.ByteString -> Maybe (Integer, BSC8.ByteString)) -> (BSC8.ByteString -> [Integer]) readILL f = unfoldr g where g s = do (n, s') <- f s return (n, BSC8.dropWhile isSpace s') main :: IO () main = do [t, a, b] <- getLL (readILL BSC8.readInteger) print $ solve t a b solve :: Integer -> Integer -> Integer -> Integer solve t a b = aa + bb - cc where c = lcm a b aa = if t `mod` a == 0 then (t `div` a) else (t `div` a) + 1 bb = if t `mod` b == 0 then (t `div` b) else (t `div` b) + 1 cc = if c >= t then 1 else if t `mod` c == 0 then (t `div` c) else (t `div` c) + 1 lcm :: Integer -> Integer -> Integer lcm a b = a `div` (gcd a b) * b