import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b, c, d] <- getIntList
    let l = lcm c d
    print $ (solve b c d l) - (solve (a-1) c d l)

solve n c d l = n - (n `div` c + n `div` d - n `div` l)