a, b, c, d = list(map(int, input().split()))

def gcd(a, b):

    if a == 0:

        return b

    return gcd(b % a, a)

def count(x, y):

    return x // y

cd = c * d // gcd(c, d)

print((b - a + 1 - count(b, c) + count(a - 1, c) - count(b, d) + count(a - 1, d) + count(b, cd) - count(a - 1, cd)))

a, b, c, d = list(map(int, input().split()))

def gcd(a, b):

    return b if a == 0 else gcd(b % a, a)

def lcm(a, b):

    return a // gcd(a, b) * b

def count(x):

    return x - (x // c) - (x // d) + (x // lcm(c, d))

print((count(b) - count(a - 1)))
a, b, c, d = list(map(int, input().split()))


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def count(x, y):
    return x // y


cd = c * d // gcd(c, d)
print(
    (
        b
        - a
        + 1
        - count(b, c)
        + count(a - 1, c)
        - count(b, d)
        + count(a - 1, d)
        + count(b, cd)
        - count(a - 1, cd)
    )
)

a, b, c, d = list(map(int, input().split()))


def gcd(a, b):
    return b if a == 0 else gcd(b % a, a)


def lcm(a, b):
    return a // gcd(a, b) * b


def count(x):
    return x - (x // c) - (x // d) + (x // lcm(c, d))


print((count(b) - count(a - 1)))

-    if a == 0: -        return b -    return gcd(b % a, a) +    return b if a == 0 else gcd(b % a, a) -def count(x, y): -    return x // y +def lcm(a, b): +    return a // gcd(a, b) * b -cd = c * d // gcd(c, d) -print( -    ( -        b -        - a -        + 1 -        - count(b, c) -        + count(a - 1, c) -        - count(b, d) -        + count(a - 1, d) -        + count(b, cd) -        - count(a - 1, cd) -    ) -) +def count(x): +    return x - (x // c) - (x // d) + (x // lcm(c, d)) + + +print((count(b) - count(a - 1)))