# https://atcoder.jp/contests/abc131/tasks/abc131_c



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

def multiple_count(x)
  B / x - (A - 1) / x
end

puts B - A + 1 - multiple_count(C) - multiple_count(D) + multiple_count(C.lcm(D))
