require 'rational'

A, B, C, D = gets.split.map(&:to_i)

range = B - A + 1
sum_val = 0
[C, D].each do |val|
  sum_val += range / val
  sum_val += 1 if (A - 1) / val < B / val - range / val
end

val = C.lcm(D)
sum_val -= range / val
sum_val -= 1 if (A - 1) / val < B / val - range / val

puts range - sum_val