A, B, C, D = gets.split(' ').map(&:to_i)
left = 0
right = 0

(0..B).each do |i|
  left += 1 if i % C != 0 and i % D != 0
end

(0..(A - 1)).each do |i|
  right += 1 if i % C != 0 and i % D != 0
end

puts left - right