a, b, c, d = gets.strip.split.map(&:to_i)

all = b - a + 1
c_mul = b / c - (a - 1) / c
d_mul = b / d - (a - 1) / d
lcm = c.lcm(d)
lcm_mul = b / lcm - (a - 1) / lcm

puts all - (c_mul + d_mul - lcm_mul)