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

ans = 0

c_sum = a%c == 0 ? b/c-a/c+1 : b/c-a/c
d_sum = a%d == 0 ? b/d-a/d+1 : b/d-a/d
l = c.lcm(d)
cd_sum = a%l == 0 ? b/l-a/l+1 : b/l-a/l

puts (b-a+1) - (c_sum + d_sum - cd_sum)