import Data.List

func::Int->Int->Int->Int
func x y z = x - (div x y) - (div x z) + (div x (lcm y z))

main::IO ()
main = do
    [a,b,c,d] <- map read . words <$> getLine
    print $ (func b c d) - (func (a-1) c d)