'use strict';
function main(input) {
  const args = input.split(' '),
        A = parseInt(args[0]),
        B = parseInt(args[1]),
        C = parseInt(args[2]),
        D = parseInt(args[3]);
  let cnt = 0;
  for (let i = A; i != B; ++i) {
    if (i % C !== 0 && i % D !== 0) {
      ++cnt;
    }
  }
  console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));