# https://atcoder.jp/contests/abc131/tasks/abc131_c

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

lcm = c.lcm(d)
puts b - a + 1 - ((b / c - am1 / c) + ( b / d - am1 / d) - (b / lcm - (am1 / lcm )) )
