"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 ans = 0;

  for(let i = Min; i <= Max; i++){
  	if((i % div1 !== 0) && (i % div2 !== 0)){
    	ans++;
    }
  }
  
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
