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

answer = 0

all = (B - A + 1)
a = (B.div(C) - (A-1).div(C))
b = (B.div(D) - (A-1).div(D))
c = (B.div(C.lcm(D)) - (A-1).div(C.lcm(D)))

p all - a - b + c
