'use strict'
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let Nums = input.split(" ");
let A = Nums[0]*1;
let B = Nums[1]*1;
let C = Nums[2]*1;
let D = Nums[3]*1;
let ans = 0;
for(let i = A; i <= B; i++){
  if( (i % C != 0) && (i % D != 0) ){
    ans++;
  }
}
console.log(ans);