import Control.Applicative
import Control.Monad
import Data.List

main = do
  [a, b, c, d] <- map (read::String -> Integer) . words <$> getLine
  print $ b - a + 1 - ((b - a + 1) `div` c) - ((b - a + 1) `div` d) + ((b - a + 1) `div` (c * d))
