def gcd(a,b)
  if b == 0
    a
  else
    gcd(b,a%b)
  end
end
def lcm(a,b)
  a*b/gcd(a,b)
end
a,b,c,d = gets.chomp.split(" ").map(&:to_i)
sum = b-a+1
sum_c = b/c - (a-1)/c
sum_d = b/d - (a-1)/d
e = lcm(c,d)
sum_e = b/e - (a-1)/e
puts sum - sum_c - sum_d + sum_e