nondividers :: Integer -> Integer -> Integer -> Integer
nondividers 0 n m = 0
nondividers k n m = k - div k n - div k m + div k (lcm n m)

count :: Integer -> Integer -> Integer -> Integer -> Integer
count a b c d = nondividers b c d - nondividers (a - 1) c d

main = do
  a:b:c:d:_ <- map (read :: String -> Integer) . words <$> getLine
  putStrLn . show $ count a b c d
