--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 | t `mod` a == 0 && t `mod` b == 0 && t `mod` c == 0 = if (c >= t) then d - 1 else d - (t `div` c) | t `mod` a == 0 && t `mod` b == 0 && t `mod` c /= 0 = if (c >= t) then d - 1 else d - (t `div` c) - 1 | t `mod` a == 0 && t `mod` b /= 0 && t `mod` c == 0 = if (c >= t) then d - 1 else d + 1 - (t `div` c) | t `mod` a == 0 && t `mod` b /= 0 && t `mod` c /= 0 = if (c >= t) then d - 1 else d + 1 - (t `div` c) - 1 | t `mod` a /= 0 && t `mod` b == 0 && t `mod` c == 0 = if (c >= t) then d - 1 else d + 1 - (t `div` c) | t `mod` a /= 0 && t `mod` b == 0 && t `mod` c /= 0 = if (c >= t) then d - 1 else d + 1 - (t `div` c) - 1 | t `mod` a /= 0 && t `mod` b /= 0 && t `mod` c == 0 = if (c >= t) then d else d + 2 - (t `div` c) | otherwise = if (c >= t) then d else d + 2 - (t `div` c) - 1 where c = lcm a b d = (t `div` a) + (t `div` b) lcm :: Integer -> Integer -> Integer lcm a b = a `div` (gcd a b) * b