def div_count(n, k, l)
  (n / k) + (n / l) - (n / k.lcm(l))
end

def main(argv)
  (a, b, c, d) = gets.chomp.split(' ').map(&:to_i)
  
  m = b - a + 1
  x = div_count(a - 1, c, d)
  y = div_count(b, c, d)
  p (m - (y - x))
end

if self.to_s == 'main' then
  main(ARGV)
end