# util functions
def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  
  def gcd_two(a, b) # assume b <= a
    return a if b % a == 0
    return gcd_two(b % a, a)
  end

  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end

def lcm(arr)
  g = gcd(arr)
  arr.map! do |e_i| e_i / g end
  mul = 1
  arr.each do |f_i|
    mul *= f_i
  end
  return mul*g
end

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]
cc = inputs[0][2]
dd = inputs[0][3]
ll = lcm([cc, dd])

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p aa
  p bb
  p cc
  p dd
  p ll
end

pd "---"

nU = bb - aa + 1
pd nU
nC = bb/cc - aa/cc
nC += 1 if aa % cc == 0
pd nC
nD = bb/dd - aa/dd
nD += 1 if aa % dd == 0
pd nD
nCandD = bb/ll - aa/ll
nCandD += 1 if aa % ll == 0

pd "---"

puts nU - nC - nD + nCandD
