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


a_lcm_num = (a / lcm)
b_lcm_num = (b / lcm)

b_lcm = (b / lcm) * lcm


lcm_num = (b_lcm - a) / lcm

puts (b - a + 1) - ((b / c) - ((a-1) / c) + (b / d) - ((a-1) / d)) + (lcm_num + 1)
