"use strict"

const main = (input) => {
    input = input.split(" ");
    const A = Number(input[0]);
    const B = Number(input[1]);
    const C = Number(input[2]);
    const D = Number(input[3]);

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

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