A, B, C, D = gets.chop.split.map(&:to_i)

all = B - A + 1
div_c = B / C - (A - 1) / C
div_d = B / D - (A - 1) / D
div_cd = B / (C * D / C.gcd(D)) - (A - 1) / (C * D / C.gcd(D))

puts all - div_c - div_d + div_cd
