a,b,c,d = gets.split.map &:to_i

c_cnt = b/c - a/c
if a % c == 0 then
	c_cnt += 1
end

d_cnt = b/d - a/d
if a % d == 0 then
	d_cnt += 1
end

lcm = c.lcm(d)

lcm_cnt = b/lcm - a/lcm
if a % lcm == 0 then
	lcm_cnt += 1
end

puts b - a + 1 - (c_cnt + d_cnt - lcm_cnt)
