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