awk -M '\
# :GBg8xLs?t
function gcd(a, b)
{
    if(a<b){tmp=a;a=b;b=tmp}
    if(b == 0)return a;
    return gcd(b, a%b);
}

# :G>.8xG\?t
function lcm(a, b)
{
    return a * b / gcd(a, b);
}
{
    A=$1; B=$2; C=$3; D=$4
    T1 = int(B/C);
    T2 = int(B/D);
    
    T3 = int(A/C);
    if(A%C==0)T3--;
    T4 = int(A/D)
    if(A%D==0)T4--;

    E = lcm(C,D)
    T5 = int(B/E)
    T6 = int(A/E)
    if(A%E==0)T6--;

    print (B-A+1) - (T1-T3) - (T2-T4) + (T5-T6)
}'