function Main(input){ 
  var A = input.split(" ")[0];
  A = parseInt(A,10);
  var B = input.split(" ")[1];
  B = parseInt(B,10);
  var C = input.split(" ")[2];
  C = parseInt(C,10);
  var D = input.split(" ")[3];
  D = parseInt(D,10);
  var sum = B - A + 1;
  var Cn = Math.floor(sum/C);
  var Dn = Math.floor(sum/D);
  var CDn = Math.floor(sum/(C*D));
  var answer = sum - (Cn + Dn - CDn);
  console.log(answer);
  
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));