def gcd(a, b)
  r = a % b
  r.zero? ? b : gcd(b, r)
end

a, b, c, d = gets.split.map(&:to_i)
g = c * d / gcd(c, d)
cnt1 = b / c - (a - 1) / c
cnt2 = b / d - (a - 1) / d
cnt3 = b / g - (a - 1) / g
puts (b - a + 1) - (cnt1 + cnt2 - cnt3)