function main(input) {
  const inputList = input.split(/\s/).map(inp => formatNum(inp));
  const A = inputList[0];
  const B = inputList[1];
  const C = inputList[2];
  const D = inputList[3];
  
  // たぶんlte
  const list = [];
  for (var i = A; i <= B; i++) {
    list.push(i);
  }
  const retList = list
  	.filter(n => 0 !== n % C)
  	.filter(m => 0 !== m % D);
  console.log(retList.length);
};

// 文字列を数値に変換
function formatNum(str) {
  return Number(str);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));
