"use strict";
    
const main = arg => {
  let Nums = arg.split(" ");
  let Min = Nums[0]*1;
  let Max = Nums[1]*1;
  let div1 = Nums[2]*1;
  let div2 = Nums[3]*1;
  let mul = div1*div2;
  let ans = 0;
  let diff = (Max - Min + 1)*1;
  let x = parseInt(diff / div1);
  let y = parseInt(diff / div2);
  let z = parseInt(diff / (mul));
    
  console.log(diff - x - y + z);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
