import Control.Monad
 
import Data.Ord
import Data.List
import Data.Function
import Data.Maybe
 
import qualified Data.ByteString.Char8 as BS
 
import Debug.Trace
 
tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined
 
readInt = read :: String -> Integer
readIntTuple = tuplify2 . map readInt . words
readIntList = map readInt . words
 
getInt = readInt <$> getLine
getIntList = readIntList <$> getLine
getIntMatrix = map readIntList . lines <$> getContents
getIntTuple = readIntTuple <$> getLine
getIntTuples = map readIntTuple . lines <$> getContents

main = do
  [a,b,c,d] <- getIntList
  print $ (f a b 1) - (f a b c) - (f a b d) + (f a b (lcm c d))

-- a以上b以下でxで割り切れる数を返す
f a b x = ((maxGuard - minGuard) `div` x) - 1
  where
    minGuard = (a-1) - ((a-1) `mod` x)  -- aより小さいxの倍数
    maxGuard = (b+x) - ((b+x) `mod` x)  -- bより大きいxの倍数
