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.to_f).ceil
lcm_b = b/lcm
# puts "#{a}と#{b}の間の#{c}の倍数の個数は#{(b/c - (a/c.to_f).ceil ) + 1} "
# puts "#{a}と#{b}の間の#{d}の倍数の個数は#{(b/d - (a/d.to_f).ceil) + 1}"
# puts "#{a}と#{b}の間の#{c}と#{d}の公倍数の個数は#{lcm_b - lcm_a + 1}"
puts b - a + 1 - (c_b - c_a + 1) - (d_b - d_a + 1) + (lcm_b - lcm_a + 1)