#include <iostream>
using namespace std;
int main() {
    int A,B,C,D;
    int i,j;
    j=0;
    cin>>A>>B>>C>>D;
    for(i=A;i<=B;i++){
        if(i%C==0||i%D==0){
            continue;
        }
        else{
            j=j+1;
        }
    }
    cout<<j<<endl;
   
}