Even if the world is full of counterfeits, I still regard it as wonderful.

Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.

The phoenix has a rather long lifespan, and reincarnates itself once every a! years. Here a! denotes the factorial of integer a, that is, a! = 1 × 2 × ... × a. Specifically, 0! = 1.

Koyomi doesn't care much about this, but before he gets into another mess with oddities, he is interested in the number of times the phoenix will reincarnate in a timespan of b! years, that is, [Image]. Note that when b ≥ a this value is always integer.

As the answer can be quite large, it would be enough for Koyomi just to know the last digit of the answer in decimal representation. And you're here to provide Koyomi with this knowledge.


-----Input-----

The first and only line of input contains two space-separated integers a and b (0 ≤ a ≤ b ≤ 10^18).


-----Output-----

Output one line containing a single decimal digit — the last digit of the value that interests Koyomi.


-----Examples-----
Input
2 4

Output
2

Input
0 10

Output
0

Input
107 109

Output
2



-----Note-----

In the first example, the last digit of $\frac{4 !}{2 !} = 12$ is 2;

In the second example, the last digit of $\frac{10 !}{0 !} = 3628800$ is 0;

In the third example, the last digit of $\frac{109 !}{107 !} = 11772$ is 2.

Difficulty: EASY

Solutions:
l = input().split()
(x, y) = (int(l[0]), int(l[1]))
if y - x >= 5:
	print('0')
else:
	f = 1
	for i in range(x + 1, y + 1):
		f = f * i
	print(f % 10)


[b, a] = list(map(int, input().split()))
ans = 1
x = b + 1
while x <= a:
	ans *= x
	if ans % 10 == 0:
		ans = 0
		break
	x += 1
ans %= 10
print(ans)


(a, b) = map(int, input().split())
res = 1
for i in range(a + 1, b + 1):
	res = res * (i % 10)
	res %= 10
	if res == 0:
		break
print(res)


(a, b) = [int(x) for x in input().strip().split()]
if a > b:
	print(0)
else:
	last = 1
	for i in range(a + 1, b + 1):
		last = last * (i % 10) % 10
		if last == 0:
			break
	print(last)


S = input().split()
(a, b) = (int(S[0]), int(S[1]))
if b - a >= 9:
	print(0)
else:
	ret = 1
	for i in range(a + 1, b + 1):
		ret *= i % 10
	print(ret % 10)


(a, b) = map(int, input().split())
if b - a >= 5:
	print(0)
else:
	ans = 1
	for x in range(a + 1, b + 1):
		ans = ans * x % 10
	print(ans)


(a, b) = map(int, input().split())
if a * b == 0:
	if a == 0 and b != 0:
		if b >= 5:
			print(0)
		else:
			t = 1
			for i in range(1, b + 1):
				t *= i
			print(t % 10)
	else:
		print(1)
elif b - a > 4:
	print(0)
else:
	t = 1
	for i in range(a + 1, b + 1):
		t *= i % 10
	print(t % 10)


class CodeforcesTask869BSolution:

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

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

	def process_task(self):
		if self.a_b[1] - self.a_b[0] < 10:
			result = 1
			for x in range(self.a_b[0] + 1, self.a_b[1] + 1):
				result *= x
			self.result = str(result)[-1]
		else:
			result = 1
			for x in range(self.a_b[1] - 9, self.a_b[1] + 1):
				result *= x
			self.result = str(result)[-1]

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


(n, m) = map(int, input().split())
res = 1
if m - n == 1:
	print(m % 10)
else:
	for i in range(n + 1, m + 1):
		if i % 5 == 0:
			print(0)
			exit(0)
		res = res * i
	print(res % 10)


(a, b) = map(int, input().split())
c = 1
for i in range(b - a):
	z = (a + i + 1) % 10
	c *= z
	c = c % 10
	if c == 0:
		break
print(c)


import functools
(a, b) = map(int, input().split(' '))
if b - a >= 10:
	print('0')
elif a == b:
	print('1')
else:
	print(str(functools.reduce(lambda x, y: y * x, range(a + 1, b + 1)) % 10))


(a, b) = map(int, input().split())
sum = 1
diff = b - a
cnt = 0
if a == b:
	print(1)
	exit(0)
if diff >= 10:
	print(0)
	exit()
while cnt <= 10:
	sum *= b % 10
	b -= 1
	if a == b:
		break
	cnt += 1
print(sum % 10)


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

def fact(x, y):
	i = y - x
	j = y
	s = 1
	if i > 4:
		return 0
	for k in range(i):
		s *= j
		j -= 1
	return s % 10
print(fact(a, b))


n = input().split()
(a, b) = (int(n[0]), int(n[1]))
ans = 1
for i in range(a + 1, min(b + 1, a + 10)):
	ans = ans % 10 * (i % 10) % 10
print(ans)


(a, b) = map(int, input().split())
if b - a >= 10:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		ans = ans * i % 10
	print(ans)


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(a, b) = r()
if b < a:
	exit(print(0))
ans = 1
for i in range(a + 1, b + 1):
	ans *= i % 10
	if not ans:
		break
print(ans % 10)


(a, b) = map(int, input().split())
if b - a >= 5:
	Fac = 10
else:
	Fac = 1
	for i in range(a + 1, b + 1):
		Fac = Fac * i % 10
print(Fac % 10)


[a, b] = list(map(int, input().split()))
res = 1
for x in range(a + 1, b + 1):
	res *= x
	if res % 10 == 0:
		print('0')
		exit(0)
print(res % 10)


(a, b) = map(int, input().split())
if b - a >= 5:
	print(0)
else:
	val = 1
	for i in range(a + 1, b + 1):
		val = val * i % 10
	print(val % 10)


from sys import *
(a, b) = map(int, stdin.readline().split())
n = b - a
if n >= 1000:
	exit(print(0))
mul = 1
for i in range(a + 1, b + 1, 1):
	mul = mul * i % 10
print(mul)


(a, b) = map(int, input().split())
if b - a > 10:
	print(0)
else:
	s = 1
	for i in range(a + 1, b + 1):
		s *= i
	print(str(s)[-1])


(a, b) = map(int, input().split())
x = 0
if b - a < 10:
	x = 1
	for i in range(a + 1, b + 1):
		x *= i
print(x % 10)


(a, b) = [int(x) for x in input().split()]
if a == b:
	print(1)
else:
	start = a + 1
	if b - start > 12:
		print(0)
	else:
		cur = 1
		for x in range(start, b + 1):
			cur = cur * x % 10
		print(cur)


(a, b) = map(int, input().split())
ans = 1
for i in range(a + 1, min(a + 11, b + 1)):
	ans = ans * i % 10 % 10
print(ans)


(a, b) = map(int, input().split())
two = 0
five = 0
res = 1
for i in range(a + 1, b + 1):
	if i % 2 == 0:
		two += 1
	elif i % 5 == 0:
		five += 1
	if two > 0 and five > 0:
		res = 0
		break
	res = res * i
res = str(res)
print(res[-1])


s = [int(i) for i in input().split(' ')]
a = s[0]
b = s[1]
d = 1
if b - a > 10:
	print(0)
else:
	for i in range(a + 1, b + 1):
		d = d * i % 10
	print(d)


(a, b) = [int(i) for i in input().split()]
if a == b:
	print(1)
else:
	a += 1
	ans = a % 10
	a += 1
	while ans != 0 and a <= b:
		last = a % 10
		ans = ans * last % 10
		a += 1
	print(ans)


import sys
input = sys.stdin.readline

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

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 - 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)]
	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

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
(a, b) = int_array()
ans = 1
for i in range(a + 1, min(b + 1, a + 11)):
	ans *= i
	if i % 10 == 0:
		break
print(ans % 10)


(a, b) = input().split(' ')
a = int(a)
b = int(b)
if b - a >= 9:
	print('0')
else:
	res = 1
	for i in range(a + 1, b + 1):
		res *= i % 10
		res %= 10
	print(str(res))


(a, b) = map(int, input().split())
if a != b:
	a = a + 1
	cifr = 1
	while a <= b and cifr != 0:
		cifr = cifr * (a % 10) % 10
		a = a + 1
	print(cifr)
else:
	print(1)


(a, b) = map(int, input().split())
if b - a >= 10:
	print(0)
elif a == b:
	print(1)
else:
	su = (a + 1) % 10
	for i in range(a + 2, b + 1):
		g = i % 10
		su = g * su % 10
	print(su)


(y, x) = map(int, input().split())
if x % 10 < x - y:
	print('0')
else:
	x %= 10
	y %= 10
	r = 1
	while x != y:
		r *= x
		r %= 10
		x -= 1
	print(r)


(a, b) = list(map(int, input().split()))
last_dig = 1
for i in range(b, a, -1):
	last_dig = last_dig * i % 10
	if i % 10 == 0:
		last_dig = 0
		break
print(last_dig)


given = input().split()
(a, b) = (int(given[0]), int(given[1]))
result = 1
for i in range(a + 1, b + 1):
	result *= i
	result %= 10
	if result == 0:
		break
print(str(int(result))[-1:])


s = [int(i) for i in input().split(' ')]
a = s[0]
b = s[1]

def fac(a, b):
	cost = 1
	cnt = 0
	for i in range(a + 1, b + 1):
		cnt = cnt + 1
		cost = cost * i
		if cnt >= 10:
			break
	return cost
cost = fac(a, b)
ans = str(cost)
print(ans[-1])


(a, b) = list(map(int, input().split()))
if b - a >= 5:
	res = 0
elif b - a == 1:
	res = b % 10
elif a == b:
	res = 1
else:
	res = 1
	a = a % 10 + 1
	b = b % 10
	if a > b:
		b += 10
	while a <= b:
		res = res * a % 10
		a += 1
print(res)


(a, b) = map(int, input().split())
if b - a > 10:
	print(0)
else:
	result = 1
	a += 1
	while a <= b:
		result *= a
		a += 1
	print(str(result)[len(str(result)) - 1:])


import os
import sys
if 'PYCHARM' in os.environ:
	sys.stdin = open('in', 'r')
(a, b) = map(int, input().split())
ans = 1
for i in range(a + 1, b + 1):
	ans = ans * i % 10
	if ans == 0:
		break
print(ans)


def pow(x, y):
	sum1 = 1
	flag = 1
	for i in range(y, x, -1):
		sum1 = sum1 * i
		if sum1 % 10 == 0:
			flag = 0
			break
	if flag == 0:
		print(0)
	else:
		print(sum1 % 10)
(x, y) = map(int, input().split())
pow(x, y)


arr = input().split(' ')
ans = 1
a = int(arr[0])
b = int(arr[1])
while ans != 0 and b > a:
	ans = b % 10 * ans
	ans = ans % 10
	b -= 1
print(ans)


(a, b) = map(int, input().split())
if b - a >= 10:
	print(0)
	exit(0)
if b == a:
	print(1)
	exit(0)
if b > a:
	k = b - a
	v = []
	for i in range(a + 1, b + 1):
		v.append(i % 10)
	ans = 1
	for i in v:
		ans *= i
	print(ans % 10)


def fct(a, b):
	val = 1
	for i in range(a + 1, b + 1):
		val = val * (i % 10) % 10
		if val == 0:
			break
	return val
(a, b) = map(int, input().split())
if b - a >= 9:
	print(0)
else:
	print(fct(a, b))


def prod(x):
	if len(x) == 0:
		return 1
	return prod(x[1:]) * x[0]
(a, b) = map(int, input().split())
print(prod(range(a + 1, b + 1)[:10]) % 10)


(a, b) = map(int, input().split())
if b < 2 or b == a:
	print(1)
elif b == a + 1:
	print(str(b)[-1])
else:
	y = max(a + 1, b - 10)
	n = 1
	for i in range(y, b + 1):
		n *= i
	print(str(n)[-1])


(a, b) = [int(i) for i in input().split()]
a = max(a, 1)
b = max(b, 1)
pr = 1
for i in range(a + 1, b + 1):
	pr = pr * i
	pr = pr % 10
	if pr == 0:
		break
print(pr)


(a, b) = [int(i) for i in input().split()]
res = 1
i = a + 1
while res and i <= b:
	res = res * (i % 10) % 10
	i += 1
print(res)


a = list(map(int, input().split(' ')))
pdt = 1
f = 0
for i in range(a[0] + 1, a[1] + 1):
	pdt = pdt * i
	if pdt % 10 == 0:
		f = 1
		break
if f == 1:
	print(0)
else:
	print(pdt % 10)


(a, b) = [int(i) for i in input().split()]
product = 1
if b - a >= 5:
	print(0)
else:
	for x in range(b, a, -1):
		if str(x)[-1] == 0:
			product = 0
			break
		product *= x
		product = int(str(product)[-1])
	print(product)


import sys

def main():
	(a, b) = map(int, input().split())
	if a == b:
		print(1)
		return
	mul = None
	for num in range(a + 1, b + 1):
		if mul is None:
			mul = num % 10
		else:
			mul = mul * (num % 10) % 10
		if mul == 0:
			print(0)
			return
	print(mul)
main()


(a, b) = map(int, input().split())
ans = 1
if a == 0:
	if b >= 10:
		print(0)
	else:
		while b > 0:
			b -= 1
			ans *= (b + 1) % 10
			ans %= 10
		print(ans)
elif b == 0:
	print(1)
elif b - a >= 10:
	print(0)
else:
	while b != a:
		ans *= b % 10
		ans %= 10
		b -= 1
	print(ans)


def factorial(f):
	if f == 0:
		return 1
	else:
		return f * factorial(f - 1)

def factorial_d(f1, f2):
	f = 1
	if f1 - f2 >= 10:
		return 0
	for j in range(f2 + 1, f1 + 1):
		f = f * j
	return f
(a, b) = map(int, input().split())
if b >= a:
	r = factorial_d(b, a)
	s = str(r)
	print(s[len(s) - 1])
else:
	print(0)


(a, b) = input().split()
a = int(a)
b = int(b)
if b - a >= 5:
	print(0)
	quit()
p = 1
i = a + 1
while i <= b:
	p = p * i
	p = p % 10
	i = i + 1
print(p)


(a, b) = map(int, input().strip().split())
if b - a >= 10:
	print(0)
else:
	prod = 1
	for i in range(a + 1, b + 1):
		prod *= i
	print(prod % 10)


(a, b) = [int(i) for i in input().split()]

def factl(a, b):
	if b - a == 0:
		return 1
	else:
		count = 1
		for i in range(a + 1, b + 1):
			count *= i
		count = int(str(count)[-1])
		return count
if b - a >= 5:
	print(0)
else:
	print(factl(a, b))


(a, b) = input().split()
a = int(a)
b = int(b)
if b - a >= 5:
	print(0)
else:
	x = b - a
	y = 1
	for i in range(x):
		y = y * (b - i) % 10
	print(y)


(a, b) = list(map(int, input().split()))
if b - a >= 10:
	print(0)
else:
	k = 1
	for i in range(a + 1, b + 1):
		k *= i
	print(k % 10)


(a, b) = map(int, input().split())
the = 1
for i in range(a + 1, min(b, a + 10) + 1):
	the *= i
print(the % 10)


(a, b) = map(int, input().split())
dif = b - a
if dif >= 10:
	print(0)
else:
	result = 1
	for i in range(dif):
		result *= b - i
	str_result = str(result)
	print(str_result[len(str_result) - 1])


(a, b) = [int(i) for i in input().strip().split()]
start = a + 1
end = b
isEven = False
answer = 1
for i in range(start, end + 1):
	digit = i % 10
	if digit == 0:
		print(0)
		exit(0)
	elif not digit & 1:
		isEven = True
	elif digit == 5:
		if isEven:
			print(0)
			exit(0)
	answer = answer * digit % 10
print(answer % 10)


import math
(n, m) = map(int, input().split())
sum = 1
if m - n >= 5:
	print(0)
else:
	for i in range(n + 1, m + 1):
		sum *= i
	print(sum % 10)


s = input()
(x, y) = (int(a) for a in s.split())
last_digit = 1
for i in range(x + 1, y + 1):
	last_digit = i % 10 * last_digit
	last_digit %= 10
	if last_digit == 0:
		break
print(last_digit)


(n, m) = map(int, input().split())
if m - n >= 5:
	print('0')
else:
	k = 1
	for i in range(n + 1, m + 1):
		k *= i
	k = str(k)
	print(k[-1])


(a, b) = map(int, input().split())
arra = []
if b - a < 6:
	for i in range(b - a):
		arra.append(a + 1 + i)
	b = 1
	for i in range(len(arra)):
		b *= arra[i]
	print(b % 10)
else:
	print(0)


import sys
input = sys.stdin.buffer.readline
(a, b) = map(int, input().split())
ans = 1
i = a + 1
while ans != 0 and i <= b:
	c = str(i)
	d = str(ans * int(c[-1]))
	ans = int(d[-1])
	i += 1
print(ans)


import sys

def get_inputs():
	data = []
	for line in sys.stdin:
		data.append([int(i) for i in line.split()])
	return (data[0][0], data[0][1])
(a, b) = get_inputs()
x = 1
if b - a < 10:
	while a < b:
		a += 1
		x = a * x % 10
else:
	x = 0
print(x)


(a, b) = map(int, input().strip().split(' '))
diff = b - a
if diff >= 5:
	print(0)
elif diff == 4:
	q = (a + 1) % 10
	w = (a + 2) % 10
	e = (a + 3) % 10
	f = (a + 4) % 10
	print(q * w * e * f % 10)
elif diff == 3:
	q = (a + 1) % 10
	w = (a + 2) % 10
	e = (a + 3) % 10
	print(q * w * e % 10)
elif diff == 2:
	q = (a + 1) % 10
	w = (a + 2) % 10
	print(q * w % 10)
elif diff == 1:
	q = (a + 1) % 10
	print(q % 10)
else:
	print(1)


(a, b) = map(int, input().split())
if a == b:
	print(1)
elif b - a < 10:
	if a % 10 < b % 10:
		p = 1
		for i in range(a % 10 + 1, b % 10 + 1):
			p = p * i
		print(p % 10)
	else:
		print(0)
else:
	print(0)


import sys
return_call = lambda : sys.exit(0)
a = list(map(int, input().split()))
x = a[1] - a[0]
ans = 1
if x >= 5:
	print('0')
	return_call()
for i in range(x):
	ans *= a[1] - i
print(str(ans)[-1])


(a, b) = map(int, input().split())
p = 1
rez = 0
for i in range(a, b):
	if b - a > 10:
		rez = 0
		break
	s = str(i + 1)
	p = p * int(s[len(s) - 1])
if b - a < 10:
	rez = p % 10
print(rez)


s = input()
a = int(s.split()[0])
b = int(s.split()[1])
x = 1
for i in range(a + 1, b + 1):
	x = x * (i % 10) % 10
	if x == 0:
		break
print(x)


(n, m) = map(int, input().split())
p = int(str(n)[-1])
q = int(str(m)[-1])
if n == m:
	print(1)
if n != m:
	if m - n >= 10:
		print(0)
	else:
		o = 1
		for i in range(n + 1, m + 1):
			o *= i
		print(str(o)[-1])


(a, b) = [int(x) for x in input().split()]
factorial = 1
for i in range(a + 1, b + 1):
	factorial = factorial % 10 * (i % 10)
	if factorial == 0:
		print('0')
		exit()
print(factorial % 10)


import random
import math

def fct(k):
	if k == 0:
		return 1
	return k * fct(k - 1)
l = list(map(int, input().split()))
a = l[0]
b = l[1]
res = 0
if b - a <= 12:
	res = 1
	p = b
	while p > a:
		res *= p
		p -= 1
print(int(res) % 10)


(a, b) = map(int, input().split())
p = 1
h = 0
for k in range(a + 1, b + 1):
	if str(k)[-1] == '0':
		print('0')
		h += 1
		break
	else:
		p *= k
if h == 0:
	print(str(p)[-1])


(n1, n2) = map(int, input().split())
if n2 - n1 > 10:
	print(0)
else:
	result = 1
	for i in range(n1 + 1, n2 + 1):
		result *= i
	print(result % 10)


(a, b) = input().split()
(a, b) = (int(a), int(b))
if b - a <= 10:
	prod = 1
	for k in range(a + 1, b + 1):
		prod *= k % 10
		prod %= 10
	print(prod)
else:
	print(0)


(a, b) = map(int, input().split())
if b - a > 5:
	print(0)
else:
	c = 1
	while b > a:
		c *= b
		b -= 1
	print(c % 10)


(a, b) = map(int, input().split())
if a == b:
	print(1)
elif b // 5 - a // 5 >= 1 and b // 2 - a // 2 >= 1 or b // 10 - a // 10 >= 1:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		ans *= i
	print(ans % 10)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
li = lambda : list(map(int, input().split()))

def solve():
	(a, b) = li()
	p = 1
	for i in range(a + 1, b + 1):
		p *= i
		if i % 10 == 0:
			break
	print(p % 10)
for _ in range(1):
	solve()


(n, m) = map(int, input().split())
if m - n > 4:
	print('0')
elif m == n:
	print('1')
else:
	ans = 1
	for i in range(n + 1, m + 1):
		ans *= i
	ans = str(ans)
	print(ans[len(ans) - 1])


(n, m) = list(map(int, input().split()))
if m - n >= 5:
	print(0)
	exit()
elif m - n == 1:
	print(m % 10)
elif m - n == 2:
	print(m * (m - 1) % 10)
elif m - n == 3:
	print(m * (m - 1) * (m - 2) % 10)
elif m - n == 4:
	print(m * (m - 1) * (m - 2) * (m - 3) % 10)
elif m - n == 0:
	print(1)


(a, b) = map(int, input().split())
if a == b:
	print(1)
elif b - a == 1:
	print(str(b)[-1])
elif b - a == 2 and (b % 5 == 2 or b % 5 == 4):
	print(2)
elif (b - a == 3 or b - a == 2) and b % 5 == 3:
	print(6)
elif (b - a == 3 or b - a == 4) and b % 5 == 4:
	print(4)
else:
	print(0)


import math as m
(low, high) = tuple(map(int, input().split(' ')))
if high - low >= 6:
	print(0)
	exit(0)
res = 1
for i in range(high, low, -1):
	res *= i
print(res % 10)


ab = [int(x) for x in input().split()]
a = ab[0]
b = ab[1]
zero = False
ans = 1
for i in range(a + 1, b + 1):
	if i % 10 == 0:
		zero = True
		break
	ans *= i % 10
if zero:
	print('0')
else:
	print(ans % 10)


import math
import re

def ria():
	return [int(i) for i in input().split()]
(a, b) = ria()
c = b - a
if c >= 20:
	print(0)
else:
	kek = 1
	for i in range(a + 1, b + 1):
		kek *= i
	print(kek % 10)


(A, B) = map(int, input().split())
i = A + 1
ans = 1
while i <= B:
	ans = ans * (i % 10)
	ans = ans % 10
	if ans % 10 == 0:
		break
	i = i + 1
print(ans)


def lastDigit(a, b):
	if a == b:
		return 1
	elif b - a >= 5:
		return 0
	else:
		ans = 1
		for i in range(a + 1, b + 1):
			ans = ans * (i % 10) % 10
		return ans % 10
data = input().split()
(N, M) = (int(data[0]), int(data[1]))
print(lastDigit(N, M))


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mp = lambda : map(int, input().split())
it = lambda : int(input())
ls = lambda : list(input().strip())
mt = lambda r: [list(mp()) for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def fibo_n(n):
	return ((1 + sqrt(5)) / 2) ** n / sqrt(5)
mod = 1000000007
(a, b) = mp()
if a == b:
	print(1)
elif b - a > 10 or int(str(a)[-1]) >= int(str(b)[-1]):
	print(0)
else:
	ans = 1
	for i in range(int(str(a)[-1]) + 1, int(str(b)[-1]) + 1):
		ans *= i
		ans %= 10
	print(ans)


(n, m) = map(int, input().split())
if m - n > 10:
	print(0)
else:
	s = 1
	for i in range(n + 1, m + 1):
		s *= i % 10
	print(s % 10)


from sys import stdin
(a, b) = [int(i) for i in stdin.readline().split(' ')]
ans = 0
if b < a + 5:
	ans = 1
	for i in range(a + 1, b + 1):
		ans = ans * (i % 10) % 10
print(ans)


(x, y) = list(map(int, input().strip().split()))
(x, y) = sorted([x, y])
if y - x > 10:
	print(0)
else:
	z = 1
	for i in range(x + 1, y + 1):
		z *= i
	print(str(z)[-1])


(a, b) = map(int, input().split())
m3 = []
t = 1
if a - b == 10:
	t = 0
else:
	for i in range(a + 1, b + 1):
		if i % 10 == 0:
			t = 0
			break
		else:
			m3.append(i)
if t == 0:
	print(0)
else:
	s = 1
	for i in range(len(m3)):
		if m3[i] % 10 != 0:
			s *= m3[i] % 10
	print(s % 10)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(a, b) = LI()
	if a + 10 < b:
		return 0
	r = 1
	for i in range(a + 1, b + 1):
		r *= i
		r %= 10
	return r
print(main())


(a, b) = input().split(' ')
(a, b) = [int(a), int(b)]
if b == a:
	Ans = 1
else:
	result = 1
	for i in range(a + 1, b + 1, 1):
		k = i % 10
		result = result * k
		result = result % 10
		if result == 0:
			break
	Ans = result
print(Ans % 10)


from sys import stdin, stdout
(a, b) = map(int, stdin.readline().split())
if b - a > 1000:
	stdout.write('0')
else:
	cnt = 1
	for i in range(a + 1, b + 1):
		cnt = cnt * i % 10
	stdout.write(str(cnt))


(a, b) = list(map(int, input().split()))
s = 1
if b - a >= 5:
	print('0')
else:
	for i in range(b, a, -1):
		s = s * i
	s = str(s)
	s = list(s)
	print(s[len(s) - 1])


def immortality(a, b):
	result = 1
	while a != b:
		a += 1
		result *= a
		result %= 10
		if result == 0:
			break
	return result
(A, B) = [int(i) for i in input().split()]
print(immortality(A, B))


(a, b) = [int(x) for x in input().split(' ')]
if abs(b - a) >= 10:
	ans = 0
else:
	c = 1
	for i in range(a + 1, b + 1):
		c *= int(str(i)[-1])
	ans = str(c)[-1]
print(ans)


(a, b) = map(int, input().split())
if b - a > 4:
	print(0)
else:
	mul = 1
	for i in range(a + 1, b + 1):
		mul *= i
	print(mul % 10)


import sys
import math
import bisect

def main():
	(n, m) = map(int, input().split())
	ans = 1
	for i in range(n + 1, m + 1):
		ans = ans * i % 10
		if ans == 0:
			break
	print(ans)
main()


p = 1
(a, b) = map(int, input().split())
for x in range(a + 1, b + 1):
	p *= x
	p %= 10
	if p == 0:
		break
print(p)


[a, b] = [int(x) for x in input().split()]
if a == 0:
	a = 1
if b == 0:
	b = 1
diff = b - a
bigNum = 1
while diff > 0:
	bigNum = bigNum * b % 10
	b -= 1
	diff -= 1
	bigNum = int(str(bigNum)[-1])
	if bigNum == 0:
		break
print(bigNum)


A = list()
while len(A) < 2:
	A += list(map(int, input().strip().split()))
a = A[0]
b = A[1]
ans = 1
for i in range(a + 1, b + 1):
	ans *= i
	if ans % 10 == 0:
		break
print(ans % 10)


def lastDigit(a, b):
	if a == b:
		return 1
	elif b - a >= 5:
		return 0
	else:
		res = 1
		for i in range(a + 1, b + 1):
			res = res * (i % 10) % 10
		return res % 10
(a, b) = map(int, input().split())
print(lastDigit(a, b))


(a, b) = map(int, input().split())
cc = range(a + 1, b + 1)
ans = 0
if b - a < 22:
	ans = 1
	for dd in cc:
		ans = ans * dd % 10
print(ans)


import math
(aaa, bbb) = map(int, input().split())
if bbb <= 500:
	jjj = math.factorial(bbb) // math.factorial(aaa)
	print(jjj % 10)
elif bbb - aaa <= 5:
	mn = 1
	for i in range(aaa + 1, bbb + 1):
		mn = mn * i
	print(mn % 10)
else:
	print(0)


def solve():
	(a, b) = [int(st) for st in input().split(' ')]
	ans = 1
	if b > a + 20:
		return 0
	for i in range(a + 1, b + 1):
		ans *= i
	return ans % 10
print(solve())


(a, b) = map(int, input().split())
_b = a + 1
k = 1
while b != a:
	k *= b
	if k % 10 == 0:
		break
	b -= 1
print(k % 10)


from math import factorial

def solve(a, b):
	if a == b:
		return 1
	if a + 1 == b:
		return str(b)[-1]
	if b - a < 5:
		ans = (a + 1) % 10
		for i in range(a + 2, b + 1):
			ans = ans % 10 * i % 10 % 10
		return ans
	return 0
(a, b) = map(int, input().strip().split())
print(solve(a, b))


(a, b) = [int(x) for x in input().split()]
r = 1
for x in range(a + 1, b + 1):
	r *= x
	if r > 9:
		r = r % 10
	if r == 0:
		break
print(r)


(a, b) = [int(x) for x in input().split()]
ans = 1
if b - a > 10:
	print('0')
else:
	for y in range(a + 1, b + 1):
		ans = y % 10 * (ans % 10) % 10
	print(ans)


(a, b) = map(int, input().split())
ans = 1
for i in range(a + 1, b + 1):
	ans *= i
	if ans % 10 == 0:
		break
print(str(ans)[-1])


(a, b) = input().split()
a = int(a)
b = int(b)
small = b - a
current = 1
if small >= 5:
	current = 0
else:
	for i in range(b, a, -1):
		current = current * (i % 10)
current = current % 10
print(current)


k = input()
k = k.split()
a1 = int(k[0])
a2 = int(k[1])
if a2 - a1 >= 5:
	print('0')
else:
	p = 1
	for i in range(a1 + 1, a2 + 1):
		p *= i % 10
	print(str(p % 10))


a = input()
a = a.split(' ')
b = int(a[1])
a = int(a[0])
if b - a >= 5:
	print(0)
else:
	j = 1
	for i in range(b, b - b + a, -1):
		j *= i
	print(str(j)[len(str(j)) - 1])


(a, b) = list(map(int, input().split()))
i = a + 1
j = 1
if b - a >= 5:
	print(0)
else:
	while i < b:
		j = j * (i % 10) * (i + 1) % 10
		j = j % 10
		i += 2
	if i == b:
		j = j * (b % 10)
		j = j % 10
	print(j)


x = list(map(int, input().split()))
a = x[0]
b = x[1]
w = b - a
t = 1
if b < a:
	print(0)
elif b == a:
	print(1)
elif w >= 10:
	print(0)
else:
	for i in range(a + 1, b + 1):
		t *= i
	t = t % 10
	print(int(t))


(l, r) = [int(i) for i in input().split()]
if r - l >= 10:
	print(0)
else:
	ans = 1
	for i in range(l + 1, r + 1):
		ans = ans * (i % 10) % 10
	print(ans)


import math
m = 1
(a, b) = map(int, input().split())
if (b % 10 >= 5 or b % 10 == 0) and b - a > 1 and (a % 10 < 5) or b - a >= 9:
	print(0)
elif a == b:
	print(1)
else:
	for i in range(b, a, -1):
		m = m * (i % 10)
		m %= 10
	print(m)


(x, y) = sorted(map(int, input().split()))
a = 1
if y - x >= 5:
	print(0)
else:
	for i in range(x + 1, y + 1):
		a *= i
	print(str(a)[-1])


inputs = [int(x) for x in input().split(' ')]
if inputs[1] >= inputs[0] + 5:
	print('0')
else:
	a = inputs[1] % 10
	b = inputs[0] % 10
	o = 1
	if a > b:
		for i in range(b + 1, a + 1):
			o *= i
		print(o % 10)
	elif a == b:
		print('1')
	else:
		print('0')


def factorial(x, y):
	m = x + 1
	res = 1
	while m != y + 1:
		res *= m % 10
		m += 1
		if res > 9:
			res %= 10
		elif res == 0:
			break
	print(res)
(x, y) = map(int, input().split())
factorial(x, y)


(a, b) = map(int, input().split())
r = 1
while a != b and r:
	a += 1
	r = r * a % 10 % 10
print(r)


from functools import reduce

def mul(a, b):
	if a * b % 10 == 0:
		print(0)
		exit()
	return a * b % 10
(a, b) = map(int, input().split())
if a == b:
	print(1)
else:
	print(reduce(mul, range(a + 1, b + 1)) % 10)


def main():
	(a, b) = [int(c) for c in input().split()]
	(div, mod) = divmod(b - a, 10)
	cnt = [div] * 10
	for i in range(mod):
		cnt[(a + 1 + i) % 10] += 1
	change = {0: [0], 1: [1], 2: [2, 4, 8, 6], 3: [3, 9, 7, 1], 4: [4, 6], 5: [5], 6: [6], 7: [7, 9, 3, 1], 8: [8, 4, 6, 2], 9: [9, 1]}
	res = 1
	no_change = {0, 1, 5, 6, 9}
	for (i, c) in enumerate(cnt):
		if c > 0:
			cc = change[i]
			res *= cc[c % len(cc) - 1]
	print(res % 10)
main()


line = input().split()
a = int(line[0])
b = int(line[1])
x = 1
if b - a < 10:
	while a < b:
		a += 1
		x = a * x % 10
else:
	x = 0
print(x)


def uppp(x):
	y = 1
	if x >= 1:
		y = x * uppp(x - 1)
	return int(y)
[a, b] = [int(i) for i in input().split()]
if a != b and b - a >= 10:
	a = a % 10
	b = b % 10 + 10
	n = int(uppp(b) / uppp(a))
elif a != b and b - a < 10:
	a = a % 10
	b = b % 10
	n = int(uppp(b) / uppp(a))
else:
	n = 1
print(int(n % 10))


import math
(a, b) = map(int, input().split())
if b <= 500:
	c = math.factorial(b) // math.factorial(a)
	print(c % 10)
elif b - a <= 5:
	d = 1
	for i in range(a + 1, b + 1):
		d = d * i
	print(d % 10)
else:
	print(0)


(a, b) = map(int, input().split())
d = [1, 1, 2, 6, 4]
if a == 0:
	print(0 if b >= 5 else d[b])
elif b == 0:
	print(1 if a <= 1 else 0)
else:
	f = 1
	x = a + 1
	while x <= b:
		f *= x
		if x % 10 == 0:
			break
		x += 1
	print(f % 10)


import math
(x, y) = map(int, input().split())
if y <= 500:
	u = math.factorial(y) // math.factorial(x)
	print(u % 10)
elif y - x <= 5:
	k = 1
	for i in range(x + 1, y + 1):
		k = k * i
	print(k % 10)
else:
	print(0)


(a, b) = tuple(map(int, input().split()))
if a > b:
	print(0)
elif a == b:
	print(1)
else:
	c = b - a
	if c >= 5:
		print(0)
	else:
		ans = 1
		for i in range(c):
			ans *= i + 1 + a
		print(str(ans)[-1])


(a, b) = map(int, input().split())
ans = 1
for num in range(a + 1, b + 1):
	num = str(num)
	intgr = int(num[len(num) - 1])
	ans *= intgr
	if ans == 0:
		break
ans = str(ans)
print(ans[len(ans) - 1])


(n, m) = map(int, input().split())
p = 1
c = m - n
if c > 10:
	print(0)
else:
	for i in range(n + 1, m + 1):
		p *= i
	print(p % 10)


def getAns(startNum, endNum):
	sum = 1
	for i in range(startNum + 1, min(b, a + 10) + 1):
		sum *= i
	return sum % 10
(a, b) = map(int, input().split())
print(getAns(a, b))


(a, b) = list(map(int, input().split()))
if a == 0 and b == 0:
	print('1')
elif a == 0 and b != 0:
	if b >= 10:
		print('0')
	else:
		sum = 1
		for i in range(b - a):
			sum *= i + a + 1
		print(sum - sum // 10 * 10)
elif b - a >= 10:
	print('0')
else:
	sum = 1
	for i in range(b - a):
		sum *= i + a + 1
	print(sum - sum // 10 * 10)


(a, b) = [int(i) for i in input().split()]
if b - a >= 10:
	print(0)
else:
	c = b - a - 1
	p = 1
	for i in range(0, c + 1):
		p = p % 10 * ((b - i) % 10) % 10
	print(p)


(n, m) = map(int, input().split(' '))
sum = 1
y = 0
for i in range(n + 1, m + 1):
	sum = sum * i
	if sum % 10 == 0:
		y = 1
		print('0')
		break
if y != 1:
	print(sum % 10)


(a, b) = map(int, input().split())
answer = 1
for i in range(b, a, -1):
	answer = answer * i
	if answer % 10 == 0:
		print(0)
		exit(0)
print(answer % 10)


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
(a, b) = (int(i) for i in input().split())
if b - a >= 10:
	print(0)
else:
	p = 1
	for i in range(a + 1, b + 1):
		p = p * (i % 10) % 10
	print(p)


a = input().split()
c = 1
for i in range(int(a[0]) + 1, int(a[1]) + 1):
	c = c * i
	if c % 10 == 0:
		break
print(c % 10)


(a, b) = map(int, input().split())
if a == b:
	print(1)
elif b - a > 4:
	print(0)
else:
	m = 1
	for x in range(1, b - a + 1):
		m *= (a + x) % 10
		m %= 10
	print(m)


(b, a) = [int(i) for i in input().split()]
s = 1
while s % 10 != 0 and b != a:
	b += 1
	s *= b
print(s % 10)


from math import *
s = input().split()
a = s[0]
b = s[1]
dl = int(b) - int(a)
if dl >= 10:
	print(0)
else:
	la = int(a[len(a) - 1])
	lb = int(b[len(b) - 1])
	ans = factorial(lb) // factorial(la)
	print(str(ans)[len(str(ans)) - 1])


(a, b) = map(int, input().split())
if a == 0:
	a = 1
if b == 0:
	b = 1
s = 0
if a == b:
	s = 1
elif a + 1 == b:
	s = (a + 1) % 10
elif a + 2 == b:
	s = (a + 1) * (a + 2) % 10
elif a + 3 == b:
	s = (a + 1) * (a + 2) * (a + 3) % 10
elif a + 4 == b:
	s = (a + 1) * (a + 2) * (a + 3) * (a + 4) % 10
print(s)


(n, m) = map(int, input().split())
res = 1
for i in range(n + 1, m + 1):
	res = res * i % 10
	if res == 0:
		break
print(res)


z = list(map(int, input().split()))
y = z[0]
x = z[1]
if x % 10 == 0 and x - y != 0:
	print(0)
elif x - y == 1:
	print(x % 10)
elif x - y == 0:
	print(1)
elif x % 10 == 9 or x % 10 == 4:
	if x - y == 2:
		print(2)
	elif x - y == 3 or x - y == 4:
		print(4)
	else:
		print(0)
elif x % 10 == 8 or x % 10 == 3:
	if x - y == 2 or x - y == 3:
		print(6)
	else:
		print(0)
elif x % 10 == 7 or x % 10 == 2:
	if x - y == 2:
		print(2)
	else:
		print(0)
else:
	print(0)


(a, b) = map(int, input().split())
prod = 1
for i in range(a + 1, b + 1):
	prod *= i
	if not prod % 10:
		break
print(prod % 10)


L = input()
L = L.split()
a = int(L[0])
b = int(L[1])

def Factorial(N):
	k = 1
	F = 1
	while k <= N:
		F *= k
		k += 1
	return F
if a == b:
	print(1)
elif a == 0:
	if b >= 5:
		print(0)
	else:
		print(Factorial(b) % 10)
else:
	i = b - a
	if i == 1:
		print(b % 10)
	else:
		f = 1
		M = 0
		t = a + f
		n = a + f + 1
		while f < i and i <= 10:
			t = t % 10
			n = n % 10
			M = t * n % 10
			f += 1
			t = M
			n = a + f + 1
		print(M)


import math
import collections
import bisect

def solve(a, b):
	product = 1
	for i in range(a + 1, b + 1):
		product *= i % 10
		product = product % 10
		if product == 0:
			return product
	return product
(a, b) = [int(s) for s in input().split()]
result = solve(a, b)
print(result)


def eternity(m, n):
	if n - m > 10:
		return 0
	result = 1
	for j in range(m + 1, n + 1):
		result *= j
	return result % 10
(a, b) = [int(i) for i in input().split()]
print(eternity(a, b))


import operator
from functools import reduce
(a, b) = (int(x) for x in input().split())
if a == b:
	print(1)
elif a + 5 < b:
	print(0)
else:
	print(reduce(lambda x, y: x * y % 10, range(a + 1, b + 1)) % 10)


(a, b) = list(map(int, input().split()))
z = b - a
if z <= 4:
	x = 1
	for i in range(z):
		x *= b
		b -= 1
else:
	x = 0
print(x % 10)


(a, b) = [int(x) for x in input().split()]
diff = b - a
ans = 1
if diff >= 10:
	ans = 0
else:
	for i in range(b - diff + 1, b + 1):
		ans *= i
		ans %= 10
print(ans)


(a, b) = [int(c) for c in input().split()]
if b - a >= 5:
	print(0)
elif a == b:
	print(1)
else:
	ans = a + 1
	for i in range(a + 2, b + 1):
		ans *= i
	print(ans % 10)


(a, b) = map(int, input().split())
q = a + 1
if b - q >= 10:
	print(0)
	exit(0)
else:
	f = 1
	for i in range(q, b + 1):
		f *= i
print(str(f)[len(str(f)) - 1])


def computeLastDigit(A, B):
	variable = 1
	if A == B:
		return 1
	elif B - A >= 5:
		return 0
	else:
		for i in range(A + 1, B + 1):
			variable = variable * (i % 10) % 10
		return variable % 10
(a, b) = map(int, input().split())
print(computeLastDigit(a, b))


(a, b) = map(int, input().split())
p = 1
while a < b and p % 10:
	a += 1
	p *= a
print(p % 10)


def f(l):
	(a, b) = l
	if b == a:
		return 1
	if b - a >= 5:
		return 0
	p = 1
	for i in range(a + 1, b + 1):
		p = p * (i % 10) % 10
	return p
l = list(map(int, input().split()))
print(f(l))


x = input().split(' ')
a = int(x[0])
b = int(x[1])

def fact(a, b):
	r = 1
	for i in range(a + 1, b + 1):
		r = r * i
	return r
if b - a >= 10:
	print(0)
else:
	print(fact(a, b) % 10)


from math import factorial
(a, b) = map(int, input().split())
p = 1
i = a + 1
while p % 10 != 0 and i <= b:
	p *= i
	i += 1
print(p % 10)


(a, b) = map(int, input().split())
z = 1
if b - a >= 5:
	print(0)
	exit(0)
for i in range(a + 1, b + 1):
	z *= i
print(z % 10)


(a, b) = list(map(int, input().split()))
b1 = a + 1
l = [b1]
if a == b:
	print(1)
	quit()
for i in range(b - a - 1):
	b1 = str(int(b1) + 1)
	l.append(int(b1[-1]))
	if len(l) > 9:
		print(0)
		quit()
score = 1
for j in l:
	score = j * score
score = str(score)
print(score[-1])


def fun(a, b):
	x = a % 10
	y = b % 10
	return x * y % 10
(a, b) = [int(i) for i in input().split()]
p = 1
for i in range(a + 1, b + 1):
	p = fun(p, i)
	if p == 0:
		break
print(p)


(a, b) = list(map(int, input().split()))
if b - a >= 5:
	print('0')
else:
	num_term = b - a
	num = 1
	for i in range(num_term):
		num = num * ((a + i + 1) % 10)
		num = num % 10
	print(num)


ab = input()
ab = ab.rstrip()
ab = ab.split(' ')
a = int(ab[0])
b = int(ab[1])
import time
if b - a >= 10:
	for i in range(a + 1, b + 1):
		if '0' == str(i)[-1]:
			break
	print(0)
else:
	c = 1
	for i in range(a + 1, b + 1):
		c *= i
	c = str(c)
	print(c[-1])


(a, b) = input().split(' ')
a = int(a)
b = int(b)
if a == b:
	ans = 1
else:
	a += 1
	ans = 1
	ans *= a % 10
	if a < b:
		a += 1
		while ans != 0 and a <= b:
			ans *= a % 10
			ans %= 10
			a += 1
print(ans)


import math
import collections
import bisect
import heapq
import time
import random
(a, b) = map(int, input().split())
x = 1
for i in range(a + 1, b + 1):
	x *= i
	x %= 10
	if x == 0:
		print(0)
		exit(0)
print(x)


import sys
(a, b) = map(int, input().split())
ans = 1
for i in range(a + 1, b + 1):
	if i % 10 == 0:
		print(0)
		sys.exit(0)
	ans %= 10
	m = i % 10
	ans *= m
print(ans % 10)


from collections import Counter, defaultdict
from math import factorial as fact
(a, b) = [int(x) for x in input().split()]
d = b - a
if d >= 10:
	print(0)
else:
	t = 1
	while b > a:
		t *= b
		b -= 1
	print(t % 10)


import sys
nums = [int(x) for x in sys.stdin.readline().split(' ')]
digit = 1
for i in range(nums[0] + 1, nums[1] + 1):
	digit *= i % 10
	digit = digit % 10
	if digit is 0:
		break
print(digit)


(a, b) = map(int, input().split())
z = 1
delta = b - a
if delta >= 10:
	print(0)
else:
	for i in range(a + 1, b + 1):
		num = int(str(i)[-1])
		z = z * num % 10
	print(z)


import math
(a, b) = input().split()
a = int(a)
b = int(b)
if b - a > 9:
	print(0)
else:
	x = 1
	for i in range(a + 1, b + 1):
		x = x * i
	print(x % 10)


def main():
	(a, b) = [int(c) for c in input().split()]
	(div, mod) = divmod(b - a, 10)
	if a == b:
		print(1)
		return
	if div > 0 or (a + 1) % 10 > (a + mod) % 10:
		print(0)
		return
	res = 1
	for i in range(a + 1, b + 1):
		res *= i % 10
	print(res % 10)
main()


(a, b) = input().split()
output = 1
c = int(b) - int(a)
if c > 4:
	output = 0
else:
	for x in range(int(b), int(a), -1):
		output *= x
y = list(str(output))
print(y[len(y) - 1])


(x, y) = input().split(' ')
x = int(x)
y = int(y)
ans = 1
if x == y:
	print(1)
	exit()
for i in range(1, 11):
	if (x + i) % 10 == 0:
		print(0)
		exit()
	if x + i == y:
		break
x = x % 10
y = y % 10
for i in range(y, x, -1):
	ans *= i
print(ans % 10)


def fact(r):
	if r == 1 or r == 0:
		return 1
	else:
		return r * fact(r - 1)
(a, b) = map(int, input().split())
t1 = str(a)
t2 = str(b)
t1 = int(t1[-1])
t2 = int(t2[-1])
if b - a > 5:
	print('0')
elif t1 > t2:
	c = fact(t1) // fact(t2)
	print(c % 10)
else:
	c = fact(t2) // fact(t1)
	print(c % 10)


(a, b) = [int(p) for p in input().split()]
if a == b:
	print(1)
elif b - a >= 5:
	print(0)
else:
	start = a + 1
	result = a + 1
	for i in range(a + 2, b + 1):
		result *= i
	print(str(result)[-1])


def solve(a, b):
	if b - a >= 10:
		return 0
	A = max(a, b)
	B = min(a, b) + 1
	res = 1
	while B <= A:
		res *= B % 10
		res %= 10
		B += 1
	return res

def main():
	N = input().split()
	(l1, l2) = (int(N[0]), int(N[1]))
	print(solve(l1, l2))
main()


def dig(num):
	return int(str(num))
(a, b) = map(int, input().split())
mult = 1
if b - a > 4:
	print(0)
else:
	for i in range(b - a):
		mult *= dig(b - i)
	print(str(mult)[-1])


(a, b) = map(int, input().split())
if b == a:
	print(1)
elif b % 10 == 0:
	print(0)
else:
	dif = b - a
	if b % 10 == 5 and dif > 1 or dif > 4:
		print(0)
	else:
		ans = 1
		while b != a:
			ans *= b
			b -= 1
		print(ans % 10)


(x, y) = map(int, input().split())
p = 1
for i in range(x + 1, y + 1):
	p = p * (i % 10) % 10
	if p == 0:
		break
print(p)


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

def CountZero(b):
	i = 0
	j = 0
	t = 0
	t1 = 0
	i1 = 0
	t2 = 0
	while True:
		if b % pow(2, i1) == b:
			break
		i1 = i1 + 1
	while True:
		if b % pow(5, i) == b:
			break
		i = i + 1
	while True:
		if b % pow(10, j) == b:
			break
		j = j + 1
	for k in range(1, i):
		t = t + b // pow(5, k)
	for l in range(1, j):
		t1 = t1 + b // pow(10, l)
	for m in range(1, i1):
		t2 = t2 + b // pow(10, m)
	t = min(t, t2)
	return t + t1
if CountZero(a) < CountZero(b):
	print(0)
else:
	t = 1
	for i in range(a + 1, b + 1):
		t = t * (i % 10) % 10
	print(t)


def main():
	n = list(map(int, input().strip().split()))
	(n, m) = tuple(n)
	temp = 1
	while m != n:
		if m % 10 == 0:
			print(0)
			return
		temp *= m
		m -= 1
	print(temp % 10)
main()


(a, b) = map(int, input().split())
if b - a >= 10:
	print(0)
else:
	res = 1
	for x in range(a + 1, b + 1):
		res = res * x % 10
	print(res)


import math
(a, b) = map(int, input().split())
num = 1
ele = str(num)
for each in range(a + 1, b + 1):
	num = num * each
	ele = str(num)
	if num % 10 == 0:
		break
if a == 0 and b == 0:
	print(1)
else:
	print(ele[-1])


(a, b) = map(int, input().split())
t = 1
while b > a:
	t = t * (b % 10)
	t = t % 10
	if t == 0:
		break
	b = b - 1
print(t)


Read = lambda : map(int, input().split())
from functools import reduce
while True:
	try:
		(a, b) = Read()
	except:
		break
	if a == b:
		print(1)
	else:
		print(0 if b > a + 10 else reduce(lambda x, y: x * y, range(a + 1, b + 1)) % 10)


(x, y) = map(int, input().split())
n = x + 1
res = n % 10
while n < y:
	n = n + 1
	if n % 10 == 0:
		res = 0
		break
	else:
		res = res * (n % 10) % 10
if x == y:
	print(1)
else:
	print(int(res))


x = list(map(int, input().split()))
z = 1
x[0] += 1
while x[0] <= x[1]:
	z = z * x[0] % 10
	x[0] += 1
	if z == 0:
		break
print(z)


x = input()
arg = x.split(' ')
y = int(arg[0])
z = int(arg[1])
a = z - y
b = abs(a)
total = 1
for i in range(max(z, y) - b + 1, max(z, y) + 1):
	total = total * i
	if total % 10 == 0:
		break
if a < 0:
	print(1 / total % 10)
else:
	print(total % 10)


from decimal import *
(a, b) = [int(i) for i in input().split(' ')]
if b - a > 5:
	print(0)
else:
	diff = Decimal(b) - Decimal(a)
	diff = int(diff)
	strb = str(b)
	eb = int(strb[-1])
	num = 1
	for i in range(diff):
		num *= eb
		if eb == 0:
			eb = 9
		else:
			eb -= 1
	res = str(num)
	print(int(res[-1]))


(a, b) = map(int, input().split())
if a == 0:
	if b > 5:
		print(0)
	else:
		w = 1
		for i in range(1, b + 1):
			w *= i
		c = str(w)
		print(c[len(c) - 1])
elif b - a < 5:
	w = 1
	for i in range(a + 1, b + 1):
		w *= i
	c = str(w)
	print(c[len(c) - 1])
else:
	print(0)


import sys
(a, b) = list(map(int, input().split()))
if b - a >= 5:
	print(0)
	sys.exit(0)
res = 1
while b != a:
	res *= b % 10
	b -= 1
print(res % 10)


x = list(map(int, input().split()))
a = x[0]
b = x[1]
if b - a >= 5:
	s = 0
else:
	s = 1
	for i in range(b, -1, -1):
		if i != a and i != 0:
			s *= i
		else:
			break
s = str(s)
print(s[-1])


import sys

def factor(a, b):
	s = 1
	for i in range(a + 1, b + 1):
		s *= i
	return s % 10
for line in sys.stdin:
	values = line.split()
	a = int(values[0])
	b = int(values[1])
	if b - a > 9:
		print(0)
	else:
		a = 1 if a == 0 else a % 10
		b = 1 if b == 0 else b % 10
		if b < a:
			b += 10
		print(factor(a, b))


X = list(map(int, input().split()))
if X[0] == X[1]:
	print(1)
	exit()
Result = 1
for i in range(X[1], X[0], -1):
	Result *= i
	if str(Result)[-1] == '0':
		print(0)
		exit()
print(str(Result)[-1])


(n, m) = [int(x) for x in input().split()]
n = max(n, 1)
m = max(m, 1)
su = 1
valid = True
for x in range(n + 1, m + 1):
	su *= x
	if su % 10 == 0:
		print(0)
		valid = False
		break
if valid:
	print(su % 10)


(a, b) = map(int, input().split(' '))
n = b - a
k = int(str(a)[-1])
if a == 0:
	k = 1
	n -= 1
p = 1
for i in range(n):
	p = int(str(p * (k + i + 1))[-1])
	if p == 0:
		break
print(str(p)[-1])


(x, y) = [int(x) for x in input().split(' ')]
(lx, ly) = (x % 10, y % 10)
if y - x >= 5:
	print(0)
elif y - x == 0:
	print(1)
elif y - x == 1:
	print(y % 10)
elif y - x == 2:
	print(ly * (ly - 1) % 10)
elif y - x == 3:
	print(ly * (ly - 1) * (ly - 2) % 10)
elif y - x == 4:
	print(ly * (ly - 1) * (ly - 2) * (ly - 3) % 10)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
(a, b) = map(int, input().split())
if a == b:
	print(1)
elif b - a >= 5:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		ans = ans * (i % 10) % 10
	print(ans % 10)


from math import factorial as fact
(a, b) = map(int, input().split(' '))
if b - a >= 10:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		ans = ans * (i % 10) % 10
	print(ans)


(a, b) = map(int, input().split())
if b > a + 10:
	print(0)
else:
	val = a + 1
	prod = 1
	while val <= b:
		prod *= val
		val += 1
	print(prod % 10)


def fact(a, b):
	pro = 1
	for x in range(a + 1, b + 1):
		pro = pro * (x % 10) % 10
		if pro == 0:
			break
	return pro
(a, b) = [int(x) for x in input().split(' ')]
result = fact(a, b)
print(result)


(a, b) = map(int, input().split())
a = max(a, 1)
b = max(b, 1)
if a + 2 - a % 2 <= b and a + 5 - a % 5 <= b:
	print(0)
elif a == b:
	print(1)
else:
	res = 1
	for i in range(a + 1, b + 1):
		res *= i
	print(res % 10)


(a, b) = input().split()
a = int(a)
b = int(b)
t = 1
for i in range(a + 1, b + 1):
	t *= i % 10
	if t % 10 == 0:
		break
print(t % 10)


(a, b) = input().split(' ')
a = int(a)
b = int(b)
ans = 1
if abs(b - a) >= 5:
	print('0')
else:
	for i in range(a + 1, b + 1):
		ans = ans * i
	print(ans % 10)


(a, b) = map(int, input().split())
mul = 1
for i in range(b, a, -1):
	mul = mul * i
	if mul % 10 == 0:
		print(0)
		exit()
mul = str(mul)
a = list(mul)
print(mul[-1])


str = input()
a = int(str[0:str.find(' ')])
b = int(str[str.find(' '):])
answ = 1
if b - a > 4:
	print(0)
else:
	while b > a:
		answ *= b
		b -= 1
	print(answ % 10)


(a, b) = map(int, input().split())
product = 1
for i in range(a + 1, min(a + 6, b + 1)):
	product *= i
print(product % 10)


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 lcm(a, b):
	return a * b // gcd(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 + 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():
	(a, b) = map(int, input().split())
	if abs(a - b) >= 10:
		print(0)
		return
	ans = 1
	for i in range(b, a, -1):
		ans *= i
	print(ans % 10)
for _ in range(1):
	solve()


def checking_func(n, m):
	if m == n:
		return 1
	if m - n > 4:
		return 0
	m = m % 100
	n = n % 100
	if m == 0:
		return 0
	total = 1
	while m > n:
		total *= m
		total %= 100
		m -= 1
	return total % 10
(pr, ia) = map(int, input().split())
print(checking_func(pr, ia))


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
dgl = lambda : list(map(int, input()))
(a, b) = f()
if b - a < 10 and b % 10 > a % 10:
	a %= 10
	b %= 10
	p = 1
	for i in range(a + 1, b + 1):
		p *= i
	print(p % 10)
elif a == b:
	print(1)
else:
	print(0)


import math
(a, b) = list(map(int, input().split(' ')))
if b - a >= 10 - a % 10:
	print(0)
else:
	s = 1
	for i in range(a + 1, b + 1):
		s *= i % 10
		s %= 10
	print(s)


l = input().split(' ')
n = int(l[0])
m = int(l[1])
res = 1
if m - n >= 10:
	print(0)
else:
	while m > n:
		res = m % 10 * res % 10
		m -= 1
	print(res)


import sys
import math
from collections import OrderedDict

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

def iinput():
	return int(input())

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

def listinput():
	return list(map(int, input().split()))
(a, b) = minput()
s = 1
for i in range(b - a):
	if b % 10 == 0:
		s = 0
		break
	else:
		s = s * b
	b -= 1
print(str(s)[-1])


d = input()
a = int(d.split(' ')[0])
b = int(d.split(' ')[1])
k = 1
for i in range(b, a, -1):
	k = k * (i % 10) % 10
	if k == 0:
		break
print(k)


(sma, lrg) = map(int, input().split())
if sma == lrg:
	print(1)
else:
	val = 1
	for i in range(sma + 1, lrg + 1):
		val = val * i
		if val % 10 == 0:
			break
	print(val % 10)


(a, b) = map(int, input().split())
ans = 1
while a < b:
	a += 1
	ans *= a
	if ans % 10 == 0:
		print(0)
		exit(0)
print(ans % 10)


(a, b) = map(int, input().split())
if a == b:
	print(1)
elif a > b:
	print(0)
else:
	diff = b - a - 1
	if diff >= 5:
		print(0)
	else:
		l = [x for x in range(b, b - diff - 1, -1)]
		c = 1
		for x in l:
			c *= x
		print('{}'.format(c)[-1])


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	(a, b) = map(int, input().split(' '))
	if a == 0 and b == 0:
		print(1)
	elif b - a >= 5:
		print(0)
	else:
		temp = int(str(b)[-1])
		boss = b - a
		ans = 1
		while boss > 0:
			ans *= temp
			temp -= 1
			boss -= 1
		print(str(ans)[-1])
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(a, b) = map(int, input().split())
if b - a > 4:
	print(0)
else:
	n = 1
	a = a + 1
	while a <= b:
		n = n * a
		a = a + 1
	n = str(n)
	print(n[-1])


from sys import stdin, stdout
data = stdin.readline().rstrip().split(' ')
a = int(data[0])
b = int(data[1])
diff = b - a
multiplied_total = 1
for i in range(a + 1, b + 1):
	multiplied_total *= i
	if multiplied_total % 10 == 0:
		multiplied_total %= 10
		break
stdout.write(str(multiplied_total)[-1])


(a, b) = map(int, input().split())
n = 1
i = a + 1
flag = 1
for i in range(a + 1, b + 1):
	if n % 10 == 0 and flag == 1:
		print(0)
		flag = 0
		break
	n *= i
if flag == 1:
	print(n % 10)


(a, b) = map(int, input().split())
if b - a >= 10:
	print('0')
elif a == b:
	print('1')
else:
	a = str(a)
	b = str(b)
	a = a[len(a) - 1]
	b = b[len(b) - 1]
	a = int(a)
	b = int(b)
	fact = 1
	if a == 0 and b == 0:
		print('0')
	else:
		if a > b:
			if b == 0:
				b = 10
			if b == 1:
				b = 11
			if b == 2:
				b = 12
			if b == 3:
				b = 13
			if b == 4:
				b = 14
			if b == 5:
				b = 15
			if b == 6:
				b = 16
			if b == 7:
				b = 17
			if b == 8:
				b = 18
			if b == 9:
				b = 19
		for i in range(b, a, -1):
			fact = fact * i
		fact = str(fact)
		fact = fact[len(fact) - 1]
		print(fact)


import random, math
(a, b) = map(int, input().split())
r = 1
if b > a + 6:
	print(0)
else:
	for i in range(a + 1, b + 1):
		r *= i % 10
	print(r % 10)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

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

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

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 read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	(a, b) = mi()
	if b - a >= 20:
		print(0)
	else:
		a = a + 1
		r = 1
		for i in range(a, b + 1):
			r = r * i % 10
		print(r)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


[a, b] = [int(num) for num in input().split()]
ans = 1
for i in range(a + 1, b + 1):
	ans = ans * (i % 10)
	ans = ans % 10
	if ans == 0:
		break
print(ans)


(a, b) = list(map(int, input().strip().split()))
if a == b:
	print(1)
elif b - a >= 5:
	print(0)
else:
	f = 1
	while 1 > 0:
		f = f * b
		b = b - 1
		if b <= a:
			break
	f = str(f)
	print(f[-1])


n = list(map(int, input().split()))
if n[0] == 0:
	n[0] = 1
if n[1] == 0:
	n[1] = 1
s = 0
l = 1
for i in range(n[1], n[0], -1):
	if i % 10 == 0:
		s = 1
		break
	a = i % 10
	l = l * a
	if l > 10:
		l = l % 10
if s == 1:
	print(0)
else:
	print(l)


(a, b) = input().split()
temp = int(b) - int(a)
if temp >= 5:
	print(0)
else:
	mul = []
	a = int(a[-1])
	A = 1
	b = int(b[-1])
	while a != b:
		a += 1
		a = a % 10
		mul.append(a)
	for i in mul:
		A *= i
	print(A % 10)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(a, b) = I()
d = b - a
x = [(a + i) % 10 for i in range(1, min(6, d + 1))]
if 0 in x or (5 in x and len(x) - 1):
	print(0)
else:
	an = 1
	for i in x:
		an *= i
	print(an % 10)


import sys
from functools import reduce
from operator import mul
(a, b) = map(lambda x: int(x), sys.stdin.readlines()[0].split())
if b - a >= 9:
	print(0)
else:
	xs = range(a + 1, b + 1)
	product = reduce(mul, xs, 1)
	print(str(product)[-1])


def last_digit(a, b):
	var = 1
	if a == b:
		return 1
	elif b - a >= 5:
		return 0
	else:
		for i in range(a + 1, b + 1):
			var = var * (i % 10) % 10
	return var % 10
(a, b) = input().split()
print(last_digit(int(a), int(b)))


ab = [int(i) for i in input().split()]
a = ab[0]
b = ab[1]
ans = 1
hasPrint = False
for i in range(b, a, -1):
	ans *= i % 10
	if ans == 0:
		print('0')
		hasPrint = True
		break
if not hasPrint:
	print(ans % 10)


def main():
	inp = input().split()
	(a, b) = list(map(int, inp))
	print(div_factor(b, a))

def div_factor(b, a):
	last_digit = 1
	for i in range(a + 1, b + 1):
		last_digit = last_digit * i % 10
		if last_digit == 0:
			return last_digit
	return last_digit
main()


(a, b) = input().split(' ')
a = int(a)
b = int(b)
result = 1
for x in range(a + 1, min(b, a + 10) + 1):
	result *= x
print(result % 10)


(a, b) = map(int, input().split())
mul = 1
rem = 0
if a == b:
	print(1)
for i in range(a + 1, b + 1):
	mul *= i
	rem = mul % 10
	if rem == 0:
		print(0)
		break
if rem != 0:
	print(rem)


import sys
(a, b) = map(int, input().split())
x = a
mul = 1
if a == b:
	print(1)
	sys.exit()
while x + 1 <= b:
	mul = mul * (x + 1) % 10
	if mul % 10 == 0:
		break
	x += 1
print(mul)


from math import *
(a, b) = map(int, input().split())
if b - a >= 5:
	print(0)
else:
	ans = 1
	for i in range(b, a, -1):
		ans *= i
		ans %= 10
	print(ans)


inp = input()
a = int(inp.split(' ')[0])
b = int(inp.split(' ')[1])
if b - a >= 5:
	print('0')
elif b == a:
	print('1')
else:
	t = b - a
	d = b % 10
	ans = 1
	for i in range(t):
		ans = ans * (d - i)
	print(ans % 10)


(num1, num2) = map(int, input().split())
factor = 1
if num2 - num1 < 10:
	for i in range(num1 + 1, num2 + 1):
		factor *= i
	print(factor % 10)
else:
	print(0)


import random
a = random.randint(0, 10 ** 18)
b = random.randint(0, 10 ** 18)
(a, b) = input().split()
a = int(a)
b = int(b)
t = 1
for i in range(a + 1, b + 1):
	t = t * i % 10
	if t == 0:
		break
print(t)


import sys
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 15
mod = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def solve(a, b):
	if b - a >= 10:
		return 0
	n = b
	ret = 1
	while n > a:
		ret = ret * n % 10
		n -= 1
	return ret

def run():
	(a, b) = LI()
	print(solve(a, b))
run()


import sys
(a, b) = sys.stdin.readline().split()
a = int(a)
b = int(b)
if b - a >= 10:
	print(0)
else:
	input = [x % 10 for x in range(a + 1, b + 1)]
	result = 1
	for x in input:
		result *= x
		result %= 10
	print(result)


(a, b) = map(int, input().strip().split(' '))
if b - a >= 10:
	print('0')
else:
	l = []
	for j in range(a + 1, b + 1):
		l.append(j)
	m = 1
	for j in range(len(l)):
		m *= l[j] % 10
	print(m % 10)


import math
(a, b) = input().split()
(a, b) = [int(a), int(b)]
c = 1
l = min(a + 10, b)
a += 1
while a <= l:
	c = c * a % 10
	a += 1
print(c)


def main():
	(a, b) = [int(x) for x in input().split()]
	ans = 1
	for i in range(1, 11):
		if i + a > b:
			break
		ans = ans * (i + a) % 10
	print(ans)
main()


import sys
(a, b) = map(int, sys.stdin.readline().split())
if a == b:
	print(1)
elif b - (a + 1) >= 5:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		ans *= i
	print(ans % 10)


def main():
	(a, b) = [int(c) for c in input().split()]
	(div, mod) = divmod(b - a, 10)
	cnt = [div] * 10
	for i in range(mod):
		cnt[(a + 1 + i) % 10] += 1
	change = [None] * 10
	for i in range(10):
		change[i] = [i]
		curr = i * i % 10
		while curr != i:
			change[i].append(curr)
			curr = i * curr % 10
	res = 1
	for (i, c) in enumerate(cnt):
		if c:
			cc = change[i]
			res *= cc[c % len(cc) - 1]
	print(res % 10)
main()


(a, b) = input().split()
c = int(b) - int(a)
result = 1
if c > 4:
	result = 0
else:
	for x in range(int(b), int(a), -1):
		result *= x
print(result % 10)


(a, b) = map(int, input().split())
isZero = False
p = a + 1
while p <= b:
	if p % 10 == 0:
		isZero = True
		break
	p += 1
if isZero:
	print(0)
	exit()
ans = 1
for i in range(a + 1, b + 1):
	ans = ans * i % 10 % 10
print(ans)


def factorial(a, b):
	result = 1
	for i in range(a + 1, b + 1):
		result *= i
	return result
(a, b) = (int(i) for i in input().split())
if b - a >= 10:
	print(0)
else:
	print(str(factorial(a, b))[-1])


(a, b) = map(int, input().split())
if b - a > 8:
	print(0)
elif a == b:
	print(1)
else:
	t = [str(i)[-1] for i in list(range(a + 1, b + 1, 1))]
	ch = 1
	for i in range(len(t)):
		ch *= int(t[i])
	print(str(ch)[-1])


(a, b) = [int(i) for i in input().split()]
proiz = 1
if b - a >= 10:
	print(0)
else:
	for i in range(a + 1, b + 1):
		proiz *= i % 10
	print(proiz % 10)


from math import factorial
[a, b] = [int(x) for x in input().split()]
if b - a >= 10:
	print(0)
else:
	ans = 1
	for i in range(a + 1, b + 1):
		x = i % 10
		ans *= x
		ans %= 10
	print(ans)


(a, b) = [int(i) for i in input().split()]
if b - a >= 10:
	print(0)
else:
	sum = 1
	for i in range(a + 1, b + 1):
		sum = sum * i
	sum = str(sum)
	print(sum[-1])


import math
f = 1
(n, k) = map(int, input().split())
for i in range(n + 1, k + 1, 1):
	f = f % 10 * (i % 10)
	if f % 10 == 0:
		break
print(f % 10)


import math
(a, b) = map(int, input().split())
ans = 1
flag = 1
for i in range(a + 1, b + 1):
	ans = ans * i
	if ans % 10 == 0:
		flag = 0
		break
if flag == 0:
	print(0)
else:
	print(ans % 10)


def last(n):
	return n % 10

def factlast(m, n):
	fact = 1
	for i in range(m + 1, n + 1):
		fact = last(last(fact) * last(i))
		if fact == 0:
			return 0
	return last(fact)
[x, y] = [int(x) for x in input().split()]
print(factlast(x, y))


(a, b) = (int(x) for x in input().split())
if not b - a < 10:
	print(0)
	exit()
a %= 10
b %= 10
if a > b:
	print(0)
elif b == a:
	print(1)
else:
	ans = 1
	for x in range(a + 1, b + 1):
		ans *= x
	ans %= 10
	print(ans)


from sys import stdin, stdout
(a, b) = map(int, stdin.readline().split())
if b - a >= 10:
	print('0')
else:
	ans = 1
	for a in range(a, b):
		ans = ans * (a + 1)
	print(str(ans % 10))


(a, b) = [int(item) for item in input().strip().split()]
d = 1
if b - a > 10:
	print(0)
else:
	for i in range(a + 1, b + 1):
		d = d * i % 10
	print(d)


(a, b) = input().split(' ')
(a, b) = (int(a), int(b))
if a == b:
	print(1)
elif b % 10 == 0:
	print(0)
else:
	c = 1
	for i in range(a + 1, b + 1):
		c *= i % 10
		if c == 0:
			break
	print(c % 10)


(a, b) = map(int, input().split())
if b - a >= 5:
	print(0)
else:
	pr = 1
	for n in range(a + 1, b + 1):
		pr *= n
	print(pr % 10)


(a, b) = map(int, input().split())
if b - a > 12:
	print(0)
else:
	res = 1
	for i in range(a + 1, b + 1):
		res *= i
	print(res % 10)


from math import factorial as fac
(a, b) = map(int, input().split())
if b - a > 5:
	print(0)
	exit()
acc = 1
for i in range(a + 1, b + 1):
	acc *= i
print(acc % 10)


(a, b) = input().split(' ')
a = int(a)
b = int(b)
if b - a >= 10:
	print('0')
else:
	l = 1
	while b > a:
		l = l * b
		b = b - 1
	print(str(l)[-1])


n = 2
mul = 1
x = [int(n) for n in input().split()]
if x[1] - x[0] > 9:
	print('0')
else:
	for f in range(x[0] + 1, x[1] + 1):
		mul = mul * f
	print(mul % 10)


readints = lambda : map(int, input().strip('\n').split())
(a, b) = readints()

def fact(n):
	if n == 0:
		return 1
	else:
		return n * fact(n - 1)
if a == 0:
	if b < 10:
		print(fact(b) % 10)
	else:
		print(0)
elif a // 10 != b // 10:
	print(0)
else:
	i = min(a % 10, b % 10)
	j = max(a % 10, b % 10)
	if i == j:
		print(1)
	else:
		ans = 1
		for f in range(i + 1, j + 1):
			ans *= f
		print(ans % 10)


(a, b) = map(int, input().split())
c = '1'
for i in range(a + 1, b + 1):
	c = int(c)
	c *= i
	c = str(c)
	c = c[len(c) - 1]
	if c == '0':
		break
print(c)


(a, b) = tuple(map(int, input().split()))
x = 1
if b - a < 10:
	while a < b:
		a += 1
		x = a * x % 10
else:
	x = 0
print(x)


(a, b) = [int(i) for i in input().split()]
if a == b:
	print(1)
elif b - a >= 5:
	print(0)
else:
	bb = b % 10
	z = b - a
	m = 1
	for i in range(z):
		m *= bb
		bb -= 1
	print(m % 10)


(A, B) = map(int, input().split())
variable = 1
if A == B:
	print(1)
elif B - A >= 5:
	print(0)
else:
	for i in range(A + 1, B + 1):
		variable = variable * (i % 10) % 10
	print(variable)


import math

def fact(a, b):
	ans = 1
	if a == 0:
		a = 1
	if b == 0:
		b = 1
	if a == 1:
		if b >= 10:
			return 0
		else:
			for i in range(a + 1, b + 1):
				ans *= i
			return str(ans)[-1]
	elif b - a + 2 >= 10:
		return 0
	else:
		for i in range(a + 1, b + 1):
			ans *= i
		return str(ans)[-1]

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
(a, b) = map(int, input().split())
print(fact(a, b))


(a, b) = map(int, input().split())
if b - a > 8:
	print(0)
elif b == a:
	print(1)
else:
	k = b // 10
	m = a // 10
	if str(k) != str(m):
		print(0)
	else:
		l1 = str(b)
		l1 = l1[-1]
		l1 = int(l1)
		l2 = str(a)
		l2 = l2[-1]
		l2 = int(l2)
		k = 1
		for i in range(l2 + 1, l1 + 1):
			k *= i
		k = str(k)
		print(k[-1])


s = input()
strs = s.split(' ')
a = int(strs[0])
b = int(strs[1])
if a < b:
	c = a
	a = b
	b = c
c = a - b
if c > 4:
	print('0')
else:
	f = 1
	e = b % 10
	for d in range(e + 1, c + e + 1):
		d = d % 10
		f *= d
	print(f % 10)


(a, b) = map(int, input().split())
f = 1
r = 0
if a == b:
	print('1')
for i in range(a + 1, b + 1):
	f *= i
	r = f % 10
	if r == 0:
		print(0)
		break
if r != 0:
	print(r)