input = gets.split.map(&:to_i)
a = input[0]
b = input[1]
c = input[2]
d = input[3]

cd = c.lcm(d)
res = [c, d, cd].map{|div| (b / div).floor - ((a - 1) / div).floor}

puts b - a + 1 - res[0] - res[1] + res[2]