input_line = gets.chomp.split(" ")
a = input_line[0].to_i
b = input_line[1].to_i
c = input_line[2].to_i
d = input_line[3].to_i
count = 0
for i in a .. b do
  if i % c == 0 || i % d == 0 then
    count += 1
  end
end
puts b - a + 1 - count