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

lcm = C.lcm(D)

puts B - B/(C.to_f).floor - B/(D.to_f).floor + B/(lcm.to_f).floor - ((A-1) - (A-1)/(C.to_f).floor - (A-1)/(D.to_f).floor + (A-1)/(lcm.to_f).floor)

