import scala.io.StdIn._

object Main extends App {

  val arr = readLine().split(" ").map(_.toLong)
  val a = arr(0)
  val b = arr(1)
  val c = arr(2)
  val d = arr(3)
  val list = (a to b).toList
  val result = list.foldLeft(0L){ (stock, num) =>
    if(num % c != 0 && num % d != 0) stock + 1
    else stock
  }
  println(result)
}
