Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on. 

Iahub has the following scheme of painting: he skips x - 1 consecutive bricks, then he paints the x-th one. That is, he'll paint bricks x, 2·x, 3·x and so on red. Similarly, Floyd skips y - 1 consecutive bricks, then he paints the y-th one. Hence he'll paint bricks y, 2·y, 3·y and so on pink.

After painting the wall all day, the boys observed that some bricks are painted both red and pink. Iahub has a lucky number a and Floyd has a lucky number b. Boys wonder how many bricks numbered no less than a and no greater than b are painted both red and pink. This is exactly your task: compute and print the answer to the question. 


-----Input-----

The input will have a single line containing four integers in this order: x, y, a, b. (1 ≤ x, y ≤ 1000, 1 ≤ a, b ≤ 2·10^9, a ≤ b).


-----Output-----

Output a single integer — the number of bricks numbered no less than a and no greater than b that are painted both red and pink.


-----Examples-----
Input
2 3 6 18

Output
3


-----Note-----

Let's look at the bricks from a to b (a = 6, b = 18). The bricks colored in red are numbered 6, 8, 10, 12, 14, 16, 18. The bricks colored in pink are numbered 6, 9, 12, 15, 18. The bricks colored in both red and pink are numbered with 6, 12 and 18.

Difficulty: EASY

Solutions:
def gcd(x, y):
	if y % x == 0:
		return x
	else:
		return gcd(y % x, x)
inp = input()
arr = inp.split(' ')
x = int(arr[0])
y = int(arr[1])
a = int(arr[2])
b = int(arr[3])
g = gcd(min(x, y), max(x, y))
l = x * y // g
i = 0
for i in range(a, a + l + 1):
	if i > b:
		break
	if i % l == 0:
		break
ans = 0
if b >= i:
	ans = (b - i) // l + 1
print(ans)


import math
string = input()
(x, y, a, b) = map(int, string.split())
m = x * y // math.gcd(x, y)
print(math.floor(b / m) - math.ceil(a / m) + 1)


from math import *

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
(x, y, a, b) = list(map(int, input().split()))
nok = x * y // gcd(x, y)
a += (nok - a % nok) % nok
b -= b % nok
print((b - a) // nok + 1)


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

def lcm(a, b):
	return a * b // gcd(a, b)
a = [int(i) for i in input().split()]
x = a[3] // lcm(a[0], a[1])
y = (a[2] - 1) // lcm(a[0], a[1])
print(x - y)


(x, y, a, b) = tuple(map(int, input().split()))

def gcd(i, j):
	while i:
		(i, j) = (j % i, i)
	return j
s = x * y // gcd(x, y)
print(b // s - (a - 1) // s)


(x, y, a, b) = map(int, input().split())
lcm = 1
c_i = 1
while c_i <= x or c_i <= y:
	if x % c_i == 0 and y % c_i == 0:
		lcm = c_i
	c_i += 1
lcm = x * y // lcm
print(int(b // lcm - (a - 1) // lcm))


(x, y, a, b) = map(int, input().split())
g = 1
while g % x or g % y:
	g += 1
print(b // g - (a - 1) // g)


import math

def get(x, y, n):
	g = math.gcd(max(x, y), min(x, y))
	lcm = x * y // g
	return n // lcm

def main():
	(x, y, a, b) = map(int, input().split())
	total = get(x, y, b) - get(x, y, a - 1)
	print(total)
main()


def GCD(a, b):
	while a % b != 0:
		(a, b) = (b, a % b)
	return b

def LCM(a, b):
	return a * b // GCD(a, b)
(x, y, a, b) = map(int, input().split())
lcm = LCM(x, y)
print(b // lcm - (a - 1) // lcm)


(x, y, a, b) = input().split()
(x, y, a, b) = (int(x), int(y), int(a), int(b))

def gcd(m, n):
	dividend = m
	divisor = n
	rem = 0
	while divisor != 0:
		rem = dividend % divisor
		dividend = divisor
		divisor = rem
	return dividend
lcm = x * y / gcd(x, y)
if a % lcm == 0:
	count = b // lcm - a // lcm + 1
else:
	count = b // lcm - a // lcm
print(int(count))


def gcd(x, y):
	if x < y:
		(x, y) = (y, x)
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def lcm(x, y):
	return x * y // gcd(x, y)
(x, y, a, b) = (int(i) for i in input().split(' '))
f = lcm(x, y)
k = b // f - (a - 1) // f
print(k)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def gcd(a, b):
	while b > 0:
		c = a % b
		a = b
		b = c
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
(x, y, a, b) = mints()
z = lcm(x, y)
aa = (a + z - 1) // z
bb = b // z
print(bb + 1 - aa)


def gcd(a, b):
	(x, y) = (max(a, b), min(a, b))
	while x % y:
		(x, y) = (y, x % y)
	return y

def test():
	assert gcd(1071, 462) == 21
	assert gcd(462, 1071) == 21
	assert gcd(81, 135) == 27
	print('test passes')

def solve(x, y, a, b):
	tmp = x * y // gcd(x, y)
	return b // tmp - (a - 1) // tmp
(x, y, a, b) = list(map(int, input().split()))
print(solve(x, y, a, b))


def GCD(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a

def LCM(a, b):
	return a * b / GCD(a, b)

def CheckMod(a, b) -> int:
	if a % b:
		return 1
	else:
		return 0
(x, y, a, b) = map(int, input().split())
lcm = LCM(x, y)
cnt = 0
print(int(b // lcm - ((a - 1) // lcm + 1) + 1))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(x, y, a, b) = map(int, input().split())
z = x * y / gcd(x, y)
print(int(b // z - (a - 1) // z))


def GCD(a, b):
	while True:
		s = a % b
		a = b
		b = s
		if b == 0:
			return a
(x, y, a, b) = map(int, input().split())
LCM = int(x * y // GCD(x, y))
print(int(b // LCM - (a - 1) // LCM))


def main():
	(x, y, a, b) = map(int, input().split())
	(u, v) = (x, y)
	while v:
		(u, v) = (v, u % v)
	v = x * y // u
	print(b // v - (a - 1) // v)
main()


from math import gcd
(x, y, a, b) = map(int, input().split())
num = x * y // gcd(x, y)
ans = b // num - a // num
if a % num == 0:
	ans += 1
print(ans)


def GCD(a, b):
	while a % b != 0:
		(a, b) = (b, a % b)
	return b

def LCM(a, b):
	return a * b // GCD(a, b)
l = input().split(' ')
(x, y, a, b) = (int(l[0]), int(l[1]), int(l[2]), int(l[3]))
lcm = LCM(x, y)
print(b // lcm - (a - 1) // lcm)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(x, y, l, r) = invr()
same = x * y // math.gcd(x, y)
tot = r // same - (l - 1) // same
print(tot)


def findlcm(a, b):
	if a > b:
		maximum = a
	else:
		maximum = b
	while True:
		if maximum % a == 0 and maximum % b == 0:
			lcm = maximum
			break
		maximum = maximum + 1
	return lcm

class CodeforcesTask340ASolution:

	def __init__(self):
		self.result = ''
		self.x_y_a_b = []

	def read_input(self):
		self.x_y_a_b = [int(x) for x in input().split(' ')]

	def process_task(self):
		mult = findlcm(self.x_y_a_b[0], self.x_y_a_b[1])
		res = 0
		left = self.x_y_a_b[2] if not self.x_y_a_b[2] % mult else mult + self.x_y_a_b[2] // mult * mult
		right = self.x_y_a_b[3] if not self.x_y_a_b[3] % mult else self.x_y_a_b[3] // mult * mult
		res = right // mult - left // mult + 1
		self.result = str(res)

	def get_result(self):
		return self.result
Solution = CodeforcesTask340ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def sm(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
(x, y, a, b) = map(int, input().split())
z = x * y // sm(x, y)
r = b // z - a // z
if a % z == 0:
	r += 1
print(r)


(x, y, a, b) = map(int, input().split())
import math
if y > x and y % x == 0:
	M = y
elif x > y and x % y == 0:
	M = x
elif x == y:
	M = x
else:
	M = x * y // math.gcd(x, y)
i = a // M
if M * i < a:
	i += 1
j = b // M + 1
print(j - i)


from collections import deque as de
import math
import sys
import re
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def dupconscount(nums):
	element = []
	freque = []
	if not nums:
		return element
	running_count = 1
	for i in range(len(nums) - 1):
		if nums[i] == nums[i + 1]:
			running_count += 1
		else:
			freque.append(running_count)
			element.append(nums[i])
			running_count = 1
	freque.append(running_count)
	element.append(nums[i + 1])
	return (element, freque)

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))

def indic():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic
(x, y, a, b) = di()
fi = lcm(x, y)
pre = math.ceil(a / fi)
sec = math.floor(b / fi)
if a <= pre * fi <= b and a <= sec * fi <= b:
	print(sec - pre + 1)
else:
	print(0)


(x, y, a, b) = map(int, input().split())
from math import gcd
g = gcd(x, y)
g = x * y // g
print(b // g - (a - 1) // g)


from math import gcd
(x, y, a, b) = map(int, input().split())
lcm = x * y // gcd(x, y)
count1 = (a - 1) // lcm
countr = b // lcm
ans = countr - count1
print(ans)


def gcd(a, b):
	if b == a:
		return a
	elif a > b:
		return gcd(a - b, b)
	else:
		return gcd(a, b - a)
inpList = input()
inp = inpList.split()
x = int(inp[0])
y = int(inp[1])
a = int(inp[2])
b = int(inp[3])
g = gcd(x, y)
l = x * y / g
count = int(b / l) - int((a - 1) / l)
print(count)


def gcd(x, y):
	while x > 0:
		if x < y:
			(x, y) = (y, x)
		x = x % y
	return y
(x, y, a, b) = (int(i) for i in input().split(' '))
z = x * y
if z == 0:
	print(0)
else:
	z = z // gcd(x, y)
	a1 = a // z
	if a % z != 0:
		a1 = a1 + 1
	b1 = b // z
	print(b1 - a1 + 1)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(x, y, a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	lcm = x * y // gcd(x, y)
	c = 0
	print(b // lcm - math.ceil(a / lcm) + 1)
for _ in range(1):
	solve()


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

def lcm(a, b):
	return a * b / gcd(a, b)
(x, y, a, b) = list(map(int, input().split(' ')))
l = lcm(x, y)
print(int(b // l - (a - 1) // l))


from math import gcd

def lcm(x, y):
	return int(x * y / gcd(x, y))
(x, y, a, b) = map(int, input().split())
L = lcm(x, y)
if a % L == 0:
	l = a // L
else:
	l = a // L + 1
u = b // L
print(u - l + 1)


from sys import stdin, stdout, stderr, setrecursionlimit
setrecursionlimit(100000)

def debug(*e):
	if not __debug__:
		print(*e, file=stderr)

def dd(*vals):
	import inspect, re
	frame = inspect.getframeinfo(inspect.stack()[1][0])
	vs = re.search('dd\\((.+)\\)', frame.code_context[0]).group(1).split(',')
	if vs:
		debug(','.join(('{0} = {1}'.format(vs[i], v) for (i, v) in enumerate(vals))))

def trace(f):

	def traced(*args, **kw):
		debug('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

def read():
	return stdin.readline().rstrip()

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readintarr(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writearr(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
import math
(x, y, a, b) = readintarr()
d = x * y / math.gcd(x, y)
bb = b - b % d
aa = a
while True:
	if aa % x == 0 and aa % y == 0:
		break
	aa += 1
dd(aa, bb, d)
r = math.ceil(int(bb - aa + 1) / d)
write(r)


from math import gcd
(x, y, a, b) = list(map(int, input().split()))
lcm = x * y // gcd(x, y)
print(b // lcm - (a - 1) // lcm)


import math

def function(x, y, a, b):
	d = math.gcd(x, y)
	l = int(x * y / d)
	a1 = 0
	b1 = 0
	if a % l != 0:
		a1 = int(math.ceil(a / l)) * l
	if a % l == 0:
		a1 = a
	if b % l == 0:
		b1 = b
	if b % l != 0:
		b1 = b - b % l
	print(int((b1 - a1) / l) + 1)
(x, y, a, b) = map(int, input().rstrip().split())
function(x, y, a, b)


def lcm(a, b):
	for i in range(b, b * b):
		if i % a == 0 and i % b == 0:
			return i
(a, b, c, d) = map(int, input().split())
if a > b:
	k = a
	a = b
	b = k
e = lcm(a, b)
if a == 1 and b == 1:
	print(d - c + 1)
else:
	value = d // e - (c - 1) // e
	print(value)


def gcd(a, b):
	c = a % b
	return gcd(b, c) if c else b
(x, y, a, b) = map(int, input().split())
z = x * y // gcd(x, y)
print(b // z - (a - 1) // z)


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)
(x, y, a, b) = MAP()
lcm = x * y // gcd(x, y)
k1 = (a - 1) // lcm
k2 = b // lcm
print(k2 - k1)


import math
(x, y, a, b) = map(int, input().split())
z = x * y // math.gcd(x, y)
res = b // z - a // z
if a % z == 0:
	print(res + 1)
else:
	print(res)


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

def compute_lcm(x, y):
	lcm = x * y // compute_gcd(x, y)
	return lcm

def solve():
	(x, y, a, b) = I()
	lo = (a - 1) // compute_lcm(x, y)
	hi = b // compute_lcm(x, y)
	print(hi - lo)
tc = 1
I = lambda : list(map(int, input().split()))
for t in range(tc):
	solve()


def compute_lcm(x, y):
	if x > y:
		greater = x
	else:
		greater = y
	while True:
		if greater % x == 0 and greater % y == 0:
			lcm = greater
			break
		greater += 1
	return lcm
(x, y, a, b) = map(int, input().split())
c = compute_lcm(x, y)
count = 0
p = a % c
q = b % c
if p == 0:
	p = a // c
else:
	p = a // c + 1
if q == 0:
	q = b // c
else:
	q = b // c
print(q - p + 1)


from fractions import *
(x, y, a, b) = map(int, input().split())
nok = x * y // gcd(x, y)
first = a // nok * nok + (nok if a % nok != 0 else 0)
second = b // nok * nok
if first > b:
	print(0)
else:
	print((second - first) // nok + (1 if second % nok == 0 else 0))


(x, y, a, b) = map(int, input().split())
from math import gcd

def lcm(a1, b1):
	return a1 * b1 // gcd(a1, b1)
l = lcm(x, y)
print(b // l - (a - 1) // l)


from math import gcd

def getLCM(a, b):
	return a * b // gcd(a, b)
s = input().split(' ')
for i in range(len(s)):
	s[i] = int(s[i])
y = getLCM(s[0], s[1])
if y > s[3]:
	print(0)
else:
	print(s[3] // y - (s[2] - 1) // y)


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

def lcm(a, b):
	return a / gcd(a, b) * b
t = input().split(' ')
(x, y, a, b) = (int(i) for i in t)
l = lcm(x, y)
print(int(b // l - (a - 1) // l + 0.5))


(x, y, a, b) = map(int, input().split())
(l, r, i) = (min(x, y), max(x, y), 1)
while True:
	if l % i == 0:
		if r % int(l / i) == 0:
			break
	i += 1
p = int(l * r / int(l / i))
if a % p == 0:
	print(int(b // p) - int(a // p) + 1)
else:
	print(int(b // p) - int(a // p))


from math import *
from collections import *

def inp():
	return map(int, input().split())

def inp_arr():
	return list(map(int, input().split()))

def lcm(a, b):
	return a * b / gcd(a, b)
(x, y, lb, ub) = inp()
print(int(ub // lcm(x, y) - (lb - 1) // lcm(x, y)))


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

def lcm(a, b):
	return a * b / gcd(a, b)
(x, y, a, b) = (int(x) for x in input().split())
flag = False
aux = a
while aux <= b:
	if aux % x == 0 and aux % y == 0:
		flag = True
		start = aux + 1
		break
	aux += 1
if flag:
	step = lcm(x, y)
	print(1 + int((b - start + 1) / step))
else:
	print(0)


int_inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mul = lambda : map(int, input().split())
mulf = lambda : map(float, input().split())
seq = lambda : list(map(int, input().split()))
import math
from collections import Counter, defaultdict
(a, b, c, d) = mul()
e = min(a, b)
f = max(a, b)
for i in range(1, e + 1):
	if f * i / e == round(f * i / e):
		e = f * i
		break
a = e
print(math.floor(d / a) - math.ceil(c / a) + 1)


def NOK(a, b):
	m = min(a, b)
	M = max(a, b)
	i = 1
	while i * M % m != 0:
		i += 1
	return i * M
I = [int(i) for i in input().split()]
(x, y, a, b) = (I[0], I[1], I[2], I[3])
nok = NOK(x, y)
ans = 0
start = a
for i in range(a, b + 1):
	if start % x == 0 and start % y == 0:
		break
	else:
		start += 1
if start > b:
	print(ans)
else:
	print(int((b - start) / nok) + 1)


(x, y, a, b) = map(int, input().split())
f = lambda x, y: f(y % x, x) if x else y
x = x // f(x, y) * y
print(b // x - (a - 1) // x)


def gcd(a, b):
	while b != 0:
		temp = b
		b = a % b
		a = temp
	return a

def lcm(a, b):
	g = gcd(a, b)
	lc = a * b // g
	return lc
while 1:
	try:
		a = list(map(int, input().split()))
		maxi = a[0] if a[0] > a[1] else a[1]
		if maxi == a[0]:
			mini = a[1]
		else:
			maxi = a[1]
			mini = a[0]
		l = lcm(maxi, mini)
		c = 0
		maxi = a[2] if a[2] > a[3] else a[3]
		if maxi == a[2]:
			mini = a[3]
		else:
			maxi = a[3]
			mini = a[2]
		print(maxi // l - (mini - 1) // l)
	except EOFError:
		break


def gcd(x, y):
	while x % y != 0:
		(x, y) = (y, x % y)
	return y
(x, y, a, b) = map(int, input().split())
d = x * y // gcd(x, y)
print(b // d - (a - 1) // d)


(a, b, x, y) = map(int, input().split())
if a > b:
	(a, b) = (b, a)
n = a * b
while b - a > 0 and a * b != 0:
	(a, b) = (b, a)
	a = a % b
n = n // b
print(y // n - (x - 1) // n)


(x, y, a, b) = map(int, input().split())
u = 0
import math
f = math.gcd(x, y)
lcm = x * y // f
print(b // lcm - (a - 1) // lcm)


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

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

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def solve():
	(x, y, a, b) = L()
	lm = lcm(x, y)
	print(math.floor(b / lm) - math.floor((a - 1) / lm))
solve()


import math
(x, y, l, r) = map(int, input().split())
temp = x * y / math.gcd(x, y)
print(math.floor(r / temp) - math.ceil(l / temp) + 1)


line = input()

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

def lcm(x, y):
	lcm = x * y // gcd(x, y)
	return lcm
line = line.split(' ')
x = int(line[0])
y = int(line[1])
a = int(line[2])
b = int(line[3])
lcm = lcm(x, y)
left = int((a - 1) / lcm)
right = int(b / lcm)
diff = right - left
print(diff)


z = [int(i) for i in input().split()]
(x, y, a, b) = (z[0], z[1], z[2], z[3])

def gcd(x, y):
	for i in range(1, y + 1):
		if x * i % y == 0:
			return x * i
print(int(b // gcd(x, y) - a // gcd(x, y) + (a % gcd(x, y) == 0)))


from math import ceil

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
a = list(map(int, input().split()))
b = a[0] * a[1] // gcd(a[0], a[1])
print(int(a[3] / b) - ceil(a[2] / b) + 1)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
(x, y, a, b) = map(int, input().split())
n = x * y // gcd(x, y)
print(b // n - (a - 1) // n)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(x, y, a, b) = I()
lcm = x * y // gcd(x, y)
ans = b // lcm - (a - 1) // lcm
print(ans)


def test(x, y, a, b):
	t = x * y // gcd(x, y)
	return b // t - (a - 1) // t

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

def main():
	s = input()
	s = list(map(int, s.split()))
	print(test(s[0], s[1], s[2], s[3]))

def __starting_point():
	main()
__starting_point()


from math import gcd
(x, y, a, b) = list(map(lambda x: int(x), input().rstrip('\n').split(' ')))
m = x * y // gcd(x, y)
out = b // m - a // m
if a % m == 0:
	out += 1
print(out)


import sys
(x, y, a, b) = map(int, sys.stdin.readline().split())

def get_lcm(x, y):
	if x > y:
		k = y
		while True:
			if k % x == 0:
				return k
			k += y
	elif x < y:
		return get_lcm(y, x)
	elif x == y:
		return x
lcm = get_lcm(x, y)
num = b // lcm - (a - 1) // lcm
print(num)


from math import gcd
(x, y, a, b) = [int(n) for n in input().split()]
if x == y:
	XY = x
else:
	XY = x * y // gcd(x, y)
count = 0
if a == b:
	if a % XY == 0:
		count += 1
else:
	count = b // XY - (a - 1) // XY
print(count)


def BCNN(x, y):
	for i in range(max(x, y), 1000000):
		if i % x == 0 and i % y == 0:
			return i

def Count(m, a, b):
	k = h = 0
	for i in range(a, b + 1):
		if i % m == 0:
			k = i
			break
	for i in range(b, a - 1, -1):
		if i % m == 0:
			h = i
			break
	if k:
		return int((h - k) / m) + 1
	else:
		return 0
(x, y, a, b) = map(int, input().split())
print(Count(BCNN(x, y), a, b))


def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)
(x, y, a, b) = map(int, input().split())
g = x * y // gcd(x, y)
print(b // g - (a - 1) // g)


(x, y, a, b) = map(int, input().split())
c = 1
i = 1
while x > 1 or y > 1:
	if i > x or i > y:
		break
	if x % i == 0 and y % i == 0:
		x = x // i
		y = y // i
		c *= i
	i += 1
c = c * x * y
(b, a) = (max(a, b), min(a, b))
i = a // c
if a % c == 0:
	i -= 1
j = b // c
print(j - i)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
(x, y, a, b) = rm()
l = x * y // math.gcd(x, y)
print(b // l - (a - 1) // l)


def nod(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		a %= b
		(a, b) = (b, a)
	return b
(x, y, a, b) = map(int, input().split())
r = x * y / nod(x, y)
l = (a + r - 1) // r
ri = b // r
print(max(0, int(ri - l + 1)))


def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	for i in range(a, 0, -1):
		if a % i == 0 and b % i == 0:
			return i

def lcm(a, b):
	return a * b // gcd(a, b)
(x, y, a, b) = [int(i) for i in input().split()]
common = lcm(x, y)
if a % common != 0:
	a = a + common - a % common
b = b - b % common
print((b - a) // common + 1)


(x, y, a, b) = map(int, input().split())

def n(x, y):
	if min(x, y) == 0:
		return max(x, y)
	else:
		return n(min(x, y), max(x, y) % min(x, y))
k = x * y // n(x, y)
print(b // k - (a - 1) // k)


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

def lcm(x, y):
	return x * y / gcd(x, y)
data = input().split(' ')
x = int(data[0])
y = int(data[1])
a = int(data[2])
b = int(data[3])
m = int(lcm(x, y))
a1 = int(b / m)
a2 = int((a - 1) / m)
print('%s' % (a1 - a2))


from math import gcd
(a, b, c, d) = map(int, input().split())
lcmm = a * b // gcd(a, b)
div_c = d // lcmm - (c - 1) // lcmm
print(div_c)


from math import gcd
(x, y, a, b) = map(int, input().split())
l = x * y // gcd(x, y)
if a % l == 0:
	print(b // l - a // l + 1)
else:
	print(b // l - a // l)


def gcd(a, b):
	while a:
		(a, b) = (b % a, a)
	return b

def lca(a, b):
	return a * b // gcd(a, b)
(x, y, a, b) = [int(x) for x in input().split()]
l = lca(x, y)
print(b // l - (a - 1) // l)


(x, y, a, b) = map(int, input().split())

def lcm(a, b):
	from math import gcd
	return a * b // gcd(a, b)
z = lcm(x, y)
print(b // z - (a - 1) // z)


(x, y, a, b) = list(map(int, input().split()))
count = 0
A = 2 * [0]
for i in range(a, b + 1):
	if i % x == 0 and i % y == 0:
		A[count] = i
		count += 1
	if count == 2:
		break
if count == 2:
	RR = A[1] - A[0]
	print((b - A[0]) // RR + 1)
else:
	print(count)


import math
(x, y, a, b) = str(input()).split()
(x, y, a, b) = (int(x), int(y), int(a), int(b))
n = x * y // math.gcd(x, y)
print(1 + b // n - (a + n - 1) // n)


(x, y, a, b) = map(int, input().split())

def gcd(x, y):
	if x % y == 0:
		return y
	else:
		return gcd(y, x % y)
n = gcd(x, y)
t = x * y / n
s = 0
u = (int(a / t) + 1) * t
if u < b:
	s = int((b - u) / t) + 1
if a % t == 0:
	s += 1
print(s)


from math import gcd, ceil, floor

def lcm(a, b):
	return a * b // gcd(a, b)
(x, y, a, b) = map(int, input().split())
m = lcm(x, y)
r1 = ceil(a / m)
r2 = floor(b / m)
print(r2 - r1 + 1)


(x, y, a, b) = map(int, input().split())

def gcd(a, b):
	while a > 0 and b > 0:
		if a > b:
			a %= b
		else:
			b %= a
	return a + b
nok = x * y // gcd(x, y)
ans = b // nok - (a - 1) // nok
print(ans)


def kmm(x, y):
	i = max(x, y)
	while 1:
		if i % x == 0 and i % y == 0:
			return i
		i += 1
(x, y, a, b) = list(map(int, input().split()))
print(b // kmm(x, y) - (a - 1) // kmm(x, y))


(x, y, a, b) = input().split(' ')
x = int(x)
y = int(y)
a = int(a)
b = int(b)

def gcd(a, b):
	if a < b:
		tmp = a
		a = b
		b = tmp
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b / gcd(a, b)
if a == b:
	if a % x == 0 and a % y == 0:
		print(1)
	else:
		print(0)
else:
	count = 0
	step = int(lcm(x, y))
	res = 0
	for i in range(a, b + 1):
		if i % step == 0:
			res = int((b - i) / step) + 1
			break
	print(res)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(x, y, a, b) = map(int, input().split())
k = x * y // gcd(x, y)
m = int(a % k == 0)
print(b // k - a // k + m)


(x, y, a, b) = map(int, input().split())
from math import *
l = x * y // gcd(x, y)
print(b // l - a // l + int(a % l == 0))


from math import *

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)
(x, y, a, b) = map(int, input().split())
num = lcm(x, y)
print(floor(b / num) - ceil(a / num) + 1)


import sys
import math

def gcd(a, b):
	if b == 0:
		return a
	r = a % b
	return gcd(b, r)
(x, y, a, b) = [int(x) for x in sys.stdin.readline().split()]
a1 = x * y / gcd(x, y)
k = int(b / a1)
l = int(a / a1)
if a % a1 == 0:
	l -= 1
print(k - l)


def editor():
	import sys
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(x, y, a, b) = I()
	import math
	lcm = x * y // math.gcd(x, y)
	ans = b // lcm - (a - 1) // lcm
	print(ans)
tc = 1
I = lambda : list(map(int, input().split()))
for t in range(tc):
	solve()


import bisect
from itertools import accumulate
import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
(x, y, a, b) = map(int, input().split())
ans1 = a * math.gcd(x, y) // (x * y)
ans2 = b * math.gcd(x, y) // (x * y)
fans = ans2 - ans1
if a % x == 0 and a % y == 0:
	fans += 1
print(fans)


import math

def main():
	[x, y, a, b] = input().split(' ')
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	mmc = x * y / math.gcd(x, y)
	ini = math.ceil(a / mmc)
	fim = math.floor(b / mmc)
	print(fim - ini + 1)
main()


import math
line = input()
params = line.split(' ')
p1 = int(params[0])
p2 = int(params[1])
a = int(params[2])
b = int(params[3])
x = max(p1, p2)
y = min(p1, p2)
mult = 1
mcm = None
while True:
	mcm = mult * x
	if mcm % y == 0:
		break
	mult += 1
first_mcm_mult = math.ceil(a / mcm)
last_mcm_mult = math.floor(b / mcm)
count = last_mcm_mult - first_mcm_mult + 1
print(count)


import sys
_gcd = lambda s, m, n: m if n == 0 else _gcd(s, n, m % n)
gcd = lambda m, n: _gcd(_gcd, m, n)
lcm = lambda m, n: m // gcd(m, n) * n
(x, y, a, b) = list(map(int, input().split()))
z = lcm(x, y)
print(b // z - (a - 1) // z)


from math import ceil

def gcd(a, b):
	return b and gcd(b, a % b) or a
(x, y, a, b) = map(int, input().split(' '))
lcm = x // gcd(x, y) * y
print(b // lcm - ceil(a / lcm) + 1)


(x, y, a, b) = (int(i) for i in input().split())
p = 1
for i in range(2, 1001):
	if x % i == 0 and y % i == 0:
		x = x // i
		y = y // i
		p *= i
print(b // (x * y * p) - (a - 1) // (x * y * p))


(x, y, a, b) = map(int, input().split())
(gcd, d) = (x, y)
while d > 0:
	(gcd, d) = (d, gcd % d)
lcm = x * y // gcd
print(b // lcm - (a - 1) // lcm)


(x, y, a, b) = map(int, input().strip().split())

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

def lcm(a, b):
	return a * b / gcd(a, b)
j = lcm(x, y)
n1 = a // j + 1
if (n1 - 1) * j < a:
	n1 += 1
n2 = b // j + 1
if (n2 - 1) * j > b:
	n2 -= 1
print(int(n2 - n1 + 1))


(x, y, a, b) = map(int, input().split())

def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
l = x * y // gcd(x, y)
k = (b - a) // l
if b % l == 0 or a % l == 0:
	print(k + 1)
else:
	print(b // l - a // l)


(x, y, a, b) = map(int, input().split())

def arch(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
c = x * y // arch(x, y)
print(b // c - (a - 1) // c)


import math
(x, y, a, b) = map(int, input().split())
l = x * y // math.gcd(x, y)
print(b // l - (a - 1) // l)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def main(x, y, a, b):
	t = x * y // gcd(x, y)
	answer = b // t - a // t
	if a % t == 0:
		answer += 1
	return answer

def init():
	(x, y, a, b) = list(map(int, input().split()))
	print(main(x, y, a, b))
init()


def gcd(a, b):
	if a < b:
		t = a
		a = b
		b = t
	if b is 0:
		return a
	return gcd(b, a % b)
(x, y, a, b) = input().split()
x = int(x)
y = int(y)
a = int(a)
b = int(b)
lcm = int(x * y / gcd(x, y))
print(b // lcm - (a - 1) // lcm)


import sys

def gcd(m, n):
	return m if n == 0 else gcd(n, m % n)

def lcm(m, n):
	return m // gcd(m, n) * n
(x, y, a, b) = list(map(int, input().split()))
z = lcm(x, y)
print(b // z - (a - 1) // z)


import math
lx = [int(x) for x in input().split()]
(a, b) = (lx[0], lx[1])
(l, r) = (lx[2], lx[3])
d = a * b / math.gcd(a, b)
print(int(r / d - math.ceil(l / d) + 1))


(x, y, a, b) = map(int, input().split())
p = 0
m = max(x, y)
while True:
	if m % x == 0 and m % y == 0:
		p = m
		break
	m += 1
p1 = 0
if a % p == 0:
	p1 = a
else:
	p1 = a + p - a % p
if p1 > b:
	print(0)
else:
	print((b - p1) // p + 1)


from collections import defaultdict, deque, Counter, OrderedDict
import threading, sys
from math import gcd

def main():
	(x, y, a, b) = map(int, input().split())
	l = x * y / gcd(x, y)
	ans = int(b // l - (a - 1) // l)
	print(ans)
main()


(x, y, a, b) = input().split()
a = int(a)
b = int(b)
x = int(x)
y = int(y)
if x < y:
	r = x
	x = y
	y = r
g = x * y
r = x % y
while r != 0:
	x = y
	y = r
	r = x % y
g = int(g / y)
if g >= a:
	num = int((b - g) / g) + 1
	if g > b:
		num = 0
else:
	if a % g == 0:
		k = a
	else:
		k = int(a / g + 1) * g
	num = int((b - k) / g) + 1
	if k > b:
		num = 0
print(num)