data = $stdin.gets
a,b,c,d = data.split(" ").map{|x| x.to_f}
ab = b - a + 1
n_c = ( (b/c).floor -   (a/c).ceil + 1 )
n_d = ( (b/d).floor -   (a/d).ceil + 1 )
lcm_cd = c.to_i.lcm(d.to_i)
n_cd = ( (b/(lcm_cd)).floor - (a/(lcm_cd)).ceil  + 1)
result = (ab - n_c - n_d + n_cd).to_i
puts result