'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let A = input[0].split(' ').map(Number)[0];
  let B = input[0].split(' ').map(Number)[1];
  let C = input[0].split(' ').map(Number)[2];
  let D = input[0].split(' ').map(Number)[3];
  let count = 0;

  for (let i = A; i <= B; i++) {
    if (i % C !== 0 && i % D !== 0) {
      count += 1;
    }
  }

  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
