a,b,c,d = gets.chomp.split(' ').map(&:to_i)
c_a = (a/c.to_f).ceil
d_a = (a/d.to_f).ceil
c_b = b/c
d_b = b/d
lcm = c.lcm(d)
lcm_a = (a/lcm).ceil
lcm_b = b/lcm

puts b - a + 1 - (c_b - c_a+1) - (d_b - d_a+1) + (lcm_b - lcm_a)