a,b,c,d = gets.chomp.split(' ').map(&:to_i)

n = b - a + 1
k = c.lcm(d) #最小公倍数

if(a % d == 0)
d_1 = (b/d - a/d + 1) #dで割れる個数
else
d_1 = (b/d - a/d) #dで割れる個数
end

if(a % c == 0)
c_1 = (b/c - a/c + 1) #cで割れる個数
else
c_1 = (b/c - a/c) #cで割れる個数
end

if(a % k == 0)
k_1 = (b/k - a/k + 1) #cとdで割れる個数
else
k_1 = (b/k - a/k) #cとdで割れる個数
end

m = c_1 + d_1 - k_1

puts n - m

