function main(input) {
  const lines = input.split('\n');
  lines.forEach(line => {
    if (line.length === 0) {
      return;
    }
    const vs = line.split(' ');
    flow(
      parseInt(vs[0], 10),
      parseInt(vs[1], 10),
      parseInt(vs[2], 10),
      parseInt(vs[3], 10)
    );
  });
}

function flow(a, b, c, d) {
  var count = 0;
  for (var i = a; i <= b; i++) {
    if (i % c !== 0 && i % d !== 0) {
      count++;
    }
  }
  console.log(count);
}

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