def gcd(x, y): 

	while(y): 

   		x, y = y, x % y 

	return x 

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

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

di=b-a+1

c1=(b//c-(a-1)//c)

c2=(b//d-(a-1)//d)

c3=(b//m-(a-1)//m)

print((di-(c1+c2-c3)))  
def gcd(x, y): 

	while(y): 

   		x, y = y, x % y 

	return x 

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

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

di=b-a+1

if a%c==0:

  c1=(b//c-a//c)+1

else:

  c1=(b//c-a//c)

if a%d==0:

  c2=(b//d-a//d)+1

else:

  c2=(b//d-a//d)

if a%m==0:

  c3=(b//m-a//m)+1

else:

  c3=(b//m-a//m)

print((di-(c1+c2-c3)))  

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


a, b, c, d = list(map(int, input().split()))
m = (c * d) // (gcd(c, d))
di = b - a + 1
c1 = b // c - (a - 1) // c
c2 = b // d - (a - 1) // d
c3 = b // m - (a - 1) // m
print((di - (c1 + c2 - c3)))

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x


a, b, c, d = list(map(int, input().split()))
m = (c * d) // (gcd(c, d))
di = b - a + 1
if a % c == 0:
    c1 = (b // c - a // c) + 1
else:
    c1 = b // c - a // c
if a % d == 0:
    c2 = (b // d - a // d) + 1
else:
    c2 = b // d - a // d
if a % m == 0:
    c3 = (b // m - a // m) + 1
else:
    c3 = b // m - a // m
print((di - (c1 + c2 - c3)))

-c1 = b // c - (a - 1) // c -c2 = b // d - (a - 1) // d -c3 = b // m - (a - 1) // m +if a % c == 0: +    c1 = (b // c - a // c) + 1 +else: +    c1 = b // c - a // c +if a % d == 0: +    c2 = (b // d - a // d) + 1 +else: +    c2 = b // d - a // d +if a % m == 0: +    c3 = (b // m - a // m) + 1 +else: +    c3 = b // m - a // m