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

def count_multiple s, e, int
  e/int - (s-1)/int
end

puts ((B-A+1) - (count_multiple(A, B, C) + count_multiple(A, B, D) - count_multiple(A, B, lcm)))