MOD=10**9+7
cnt=0; sum=0; prev=nil; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,c,d=gsmi

# U-(Cで割り切れる)-(Dで割り切れる)+(CとDで割り切れる)
all = b-a+1
[c,d].each do |i|
  num = i
  cnt = b/num - (a-1)/num
  all -= cnt
end

lcm = c.lcm(d)
cnt = b/lcm - (a-1)/lcm
all += cnt

puts all