Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.

In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of r burles (1 ≤ r ≤ 9).

What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of r burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.


-----Input-----

The single line of input contains two integers k and r (1 ≤ k ≤ 1000, 1 ≤ r ≤ 9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from "10-burle coins". 

Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.


-----Output-----

Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change. 


-----Examples-----
Input
117 3

Output
9

Input
237 7

Output
1

Input
15 2

Output
2



-----Note-----

In the first example Polycarp can buy 9 shovels and pay 9·117 = 1053 burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.

In the second example it is enough for Polycarp to buy one shovel.

In the third example Polycarp should buy two shovels and pay 2·15 = 30 burles. It is obvious that he can pay this sum without any change.

Difficulty: EASY

Solutions:
s = input().split()
k = int(s[0])
r = int(s[1])
for i in range(1, 10):
	if k * i % 10 == 0:
		print(i)
		break
	elif (k * i - r) % 10 == 0:
		print(i)
		break


t = input
p = print
r = range
(k, R) = map(int, t().split())
reminder = k % 10
ans = 1
while reminder != 0:
	if reminder == R:
		break
	reminder += k % 10
	reminder %= 10
	ans += 1
p(ans)


(k, r) = [int(i) for i in input().split()]
for n in range(1, 11):
	tmp = k * n % 10
	if tmp == 0 or tmp == r:
		print(n)
		break


from sys import stdin as fin
(k, r) = map(int, fin.readline().split())
cur = 0
while cur < 10 * k:
	cur += r
	if not cur % k:
		print(cur // k)
		break
	cur += 10 - r
	if not cur % k:
		print(cur // k)
		break
else:
	print(10)


a = input()
a = a.split()
num = int(a[0])
num2 = int(a[1])
if num % 10 == 0:
	print(1)
elif num == num2:
	print(1)
i = 1
while num * i % 10 != num2:
	i += 1
	if num * i % 10 == 0:
		break
if num != num2 and num % 10 != 0:
	print(i)


i = input()
L = i.split()
n = int(L[0])
r = int(L[1])
R = 0
t = True
while t:
	if n % 10 == 0 or (n - r) % 10 == 0:
		t = False
	n += int(L[0])
n -= int(L[0])
R = n // int(L[0])
print(R)


(k, r) = map(int, input().split())

def do(k, r):
	for i in range(1, 11):
		if i * k % 10 == 0:
			return i
		if (i * k - r) % 10 == 0:
			return i
print(do(k, r))


(k, r) = map(int, input().split())
x = 1
while 0 != k * x % 10 != r:
	x = x + 1
print(x)


(price, r) = [int(i) for i in input().split(' ')]
if price % 10 == 0:
	print(1)
else:
	num = 1
	while True:
		if num * price % 10 == r or num * price % 10 == 0:
			print(num)
			break
		num += 1


(price, coins) = [int(i) for i in input().split()]
number_of_shovels = 1
while True:
	n = price * number_of_shovels // 10
	if n * 10 + coins == price * number_of_shovels or price * number_of_shovels % 10 == 0:
		break
	number_of_shovels += 1
print(number_of_shovels)


(k, r) = list((int(a) for a in input().split()))
k %= 10
p = k
c = 1
while p != 0 and p != r:
	p = (p + k) % 10
	c += 1
print(c)


nums = list(map(int, input().split()))
price = nums[0]
r = nums[1]
num_pecies = 1
while True:
	tot_price = price * num_pecies
	if tot_price % 10 == 0 or tot_price % 10 == r:
		break
	num_pecies += 1
print(num_pecies)


s = input()
a = s.split()
for i in range(len(a)):
	a[i] = int(a[i])
sum = 1
while sum <= 10:
	if a[0] * sum % 10 == a[1]:
		break
	else:
		sum += 1
if sum > 10:
	j = 1
	while j <= 10:
		if a[0] * j % 10 == 0:
			break
		else:
			j += 1
if sum <= 10:
	print(sum)
else:
	print(j)


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


(n, k) = map(int, input().split())
(count, i) = (0, 1)
while True:
	count += 1
	if n * i % 10 == k or n * i % 10 == 0:
		break
	i += 1
print(count)


import sys
input = lambda : sys.stdin.readline().strip()
(k, r) = map(int, input().split())
i = 1
while i < 10:
	if k * i % 10 == r or k * i % 10 == 0:
		print(i)
		exit()
	else:
		i += 1
print(10)


(n, t) = [int(x) for x in input().split()]
k = n
s = 1
while (k - t) % 10 != 0:
	if k % 10 != 0:
		k += n
		s += 1
	else:
		break
print(s)


(cost, coin) = [int(x) for x in input().split()]
i = 1
while True:
	x = i * cost
	if x % 10 == 0 or x % 10 == coin:
		print(i, end='')
		break
	i += 1


def find_num_shovels(cost, change):
	for i in range(1, 10000):
		if i * cost % 10 == 0:
			print(i)
			return
		elif (i * cost - change) % 10 == 0:
			print(i)
			return
(cost, change) = map(int, input().split())
find_num_shovels(cost, change)


(k, r) = map(int, input().split())
amt = 1
while (k * amt - r) % 10 != 0 and k * amt % 10 != 0:
	amt += 1
print(amt)


(k, r) = map(int, input().split())
s = i = 0
while True:
	i += 1
	s += k
	if (s - r) % 10 == 0 or s % 10 == 0:
		print(i)
		break


(s_price, change) = map(int, input().split())
counter = 1
while 0 != s_price * counter % 10 != change:
	counter += 1
print(counter)


(k, r) = map(int, input().split())
i = 1
while i < 10:
	if i * k % 10 == r or i * k % 10 == 0:
		print(i)
		break
	i += 1
else:
	print(10)


import sys
input = sys.stdin.readline

def main():
	(k, r) = map(int, input().split())
	if k % 10 == 0:
		print(1)
		return
	cnt = 1
	ans = k
	while ans % 10 != r and ans % 10 != 0:
		ans += k
		cnt += 1
	print(cnt)
main()


(k, r) = map(int, input().split())
for i in range(1, 10):
	l = int(str(k * i)[-1])
	if l == r or l == 0:
		print(i)
		exit(0)


import sys

def i():
	return input()

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

def li():
	return input().split()

def mi():
	return list(map(int, input().split()))
(k, r) = mi()
c = 0
n = 0
while True:
	c += k
	n += 1
	if (c - r) % 10 == 0 or c % 10 == 0:
		break
print(n)


(n, m) = map(int, input().strip().split())
i = 1
c = 1
a = n
while n % 10 != 0 and n % 10 != m:
	i += 1
	n += a
	c += 1
print(c)


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


(k, r) = list(map(int, input().split()))
i = 1
while True:
	if k * i % 10 == r:
		print(i)
		break
	if k * i % 10 == 0:
		print(i)
		break
	else:
		i += 1


k = [int(i) for i in input().split()]
l = 10
for i in range(1, 10):
	if k[0] * i % 10 == k[1] or k[0] * i % 10 == 0:
		l = i
		break
print(l)


(k, r) = map(int, input().split())
for i in range(1, 11):
	t = k * i % 10
	if t == r or t == 0:
		print(i)
		break


s = input().split()
k = int(s[0])
r = int(s[1])
num = 1
flag = True
while flag:
	if num * k % 10 == 0 or num * k % 10 == r:
		flag = False
		break
	num += 1
print(num)


import sys
input = sys.stdin.readline
(k, r) = map(int, input().split())
k %= 10
ans = 10
for i in range(1, 11):
	if k * i % 10 == r or k * i % 10 == 0:
		print(i)
		break


(k, r) = input().split()
k = int(k)
r = int(r)
val = k
c = 1
while True:
	if val % 10 == 0 or val % 10 == r:
		break
	else:
		c += 1
		val += k
print(c)


(k1, r) = map(int, input().split())
count = 2
k = k1
while k % 10 != r and k % 10 != 0:
	k = k1 * count
	count += 1
print(count - 1)


(k, r) = map(int, input().split())
for i in range(1, 11):
	if i * k % 10 in (0, r):
		print(i)
		exit()


(k, r) = map(int, input().split())
k1 = k
i = 1
kek = True
while kek:
	if k1 % 10 == r or k1 % 10 == 0:
		kek = False
	else:
		i += 1
		k1 += k
print(i)


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


(k, r) = map(int, input().split())
temp = k
i = 0
while True:
	x = k - r
	if x % 10 == 0 or k % 10 == 0:
		i += 1
		break
	else:
		i += 1
		k += temp
print(i)


(k, r) = map(int, input().split())
n = 1
while k * n % 10 not in [0, r]:
	n += 1
print(n)


(k, r) = map(int, input().split())
try:
	for i in range(1, 10):
		if k * i % 10 == r or k * i % 10 == 0:
			raise AssertionError(i)
except AssertionError as answer:
	print(*answer.args)
else:
	print(10)


(k, r) = map(int, input().split())
sum = k
num = 1
while sum % 10 != r and sum % 10 != 0:
	num += 1
	sum += k
print(num)


(k, r) = map(int, input().split())
i = 1
sum = k
while sum % r != 0 or sum % 10 != 0:
	if sum % 10 == r:
		break
	elif sum % 10 == 0:
		break
	sum += k
	i += 1
print(i)


(k, r) = map(int, input().split())
a = k // 10
if k % 10 == 0 or a - r == k or a + r == k:
	print(1)
else:
	i1 = 1
	i2 = 1
	i3 = 1
	while (k * i1 - r) % 10 != 0:
		i1 += 1
		if i1 == 1000:
			break
	while (k * i2 + r) % 10 != 0:
		i2 += 1
		if i2 == 1000:
			break
	while k * i3 % 10 != 0:
		i3 += 1
		if i3 == 1000:
			break
	if i1 != 1000:
		print(i1)
	elif i2 != 1000:
		print(i2)
	elif i3 != 1000:
		print(i3)


(k, r) = [int(i) for i in input().strip().split()]
flag = True
burles = 1
while flag:
	if k * burles % 10 == 0 or (k * burles - r) % 10 == 0:
		print(burles)
		flag = False
	else:
		burles += 1


entrada = list(map(int, input().split()))
precindapahvemformatura = entrada[0]
moedas = entrada[1]
mod = precindapahvemformatura % 10
for i in range(1, 1000):
	total = precindapahvemformatura * i
	if total % 10 == 0 or total % 10 == moedas:
		print(i)
		break


[k, r] = list(map(int, input().split()))
for i in range(0, 11):
	if i * k % 10 == r:
		break
	if i * k % 10 == 0 and i > 0:
		break
print(i)


(k, r) = map(int, input().split())
flag = True
i = 1
while flag:
	n = k * i
	if (n - r) % 10 == 0:
		print(i)
		flag = False
	if n % 10 == 0:
		print(i)
		flag = False
	i = i + 1


def solve(arr):
	value = arr[0]
	demon = arr[1]
	counter = 1
	while True:
		if (counter * value - demon) % 10 == 0 or counter * value % 10 == 0:
			print(counter)
			break
		else:
			counter += 1
arr = input().split()
arr = [int(x) for x in arr]
solve(arr)


i = 1
(X, Y) = input().split(' ')
result = 0
rem = 0
while True:
	result = int(X) * i
	rem = result / 10
	c = str(rem)
	y = c.find('.')
	z = c[y + 1:y + 2]
	rem = int(z)
	if rem == int(Y) or rem == 0:
		break
	i += 1
print(i)


(k, h) = map(int, input().split())
i = 1
while 0 != k * i % 10 != h:
	i += 1
print(i)


x = input().split(' ')
s = int(x[0])
r = int(x[1])
k = 1
while True:
	t = k * s
	if t % 10 == 0:
		break
	elif (t - r) % 10 == 0:
		break
	k += 1
print(k)


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


(x, y) = input().split()
n = int(x)
r = int(y)
for i in range(1, 100000000):
	if i * n % 10 == r or i * n % 10 == 0:
		print(i)
		break


li = list(map(int, input().split(' ')))
i = 1
f = li[0]
for x in range(1, 10000):
	if li[0] * x % 10 == 0 or li[0] * x % 10 == li[1]:
		print(x)
		break


(p, r) = map(int, input().split())
print(min((i for i in range(1, 11) if i * p % 10 in [0, r])))


(price, demo) = [int(x) for x in input().split()]
i = 1
while i > 0:
	if (price * i - demo) % 10 == 0 or price * i % 10 == 0:
		break
	else:
		i += 1
print(i)


(n, k) = map(int, input().split())
count = 1
x = n
while n % 10 != 0 and n % 10 != k:
	n += x
	count += 1
print(count)


import sys
input = sys.stdin.readline
(k, r) = map(int, input().split())
cost = k
cnt = 1
while cost % 10 != r and cost % 10 != 0:
	cost += k
	cnt += 1
else:
	print(cnt)


f = lambda : map(int, input().split())
(p, c) = f()
l = [i for i in range(1, 10) if p % 10 * i % 10 == c or p % 10 * i % 10 == 0]
print(l[0])


(k, r) = (int(x) for x in input().split())
answer = 1
amount = k
while amount % 10 != r and amount % 10 != 0:
	answer += 1
	amount += k
print(answer)


(a, b) = list(map(int, input().split()))
c = 1
while True:
	if a * c % 10 == 0 or (a * c - b) % 10 == 0:
		break
	else:
		c += 1
print(c)


(n, m) = map(int, input().split())
c = 1
a = n % 10
z = a
while z % 10 != m and z % 10 != 0:
	c += 1
	z = a * c
	if c == 10:
		break
print(c)


def main():
	(k, r) = map(int, input().split())
	n = 0
	ans = int()
	while True:
		if n != 0 and 10 * n % k == 0:
			ans = 10 * n // k
			break
		if (10 * n + r) % k == 0:
			ans = (10 * n + r) // k
			break
		n += 1
	print(str(ans))
main()


(a, b) = input().split()
a = int(a, 10)
b = int(b, 10)
i = 1
while i != 0:
	k = a * i
	c = i
	if (k - b) % 10 == 0 or k % 10 == 0:
		i = 0
	else:
		i += 1
print(c)


(k, r) = map(int, input().split())
jumlah_beli = 1
for i in range(11):
	harga = k * jumlah_beli
	harga = str(harga)
	ambil = harga[-1]
	ambil = int(ambil)
	if ambil == 0:
		break
	if ambil == r:
		break
	harga = int(harga)
	jumlah_beli += 1
print(jumlah_beli)


(k, r) = [int(x) for x in input().split(' ')]
z = 0
x = 1
while True:
	if k * x % 10 == 0 or (k * x - r) % 10 == 0:
		break
	else:
		x += 1
		z += 1
print(z + 1)


(a, b) = map(int, input().split())
i = 0
c = a
while 1:
	i = i + 1
	a = i * c
	if a % 10 == b or a % 10 == 0:
		print(i)
		break


(price, cost) = (0, 0)
(k, r) = input().split()
mar = True
k = int(k)
r = int(r)
while mar:
	if price % 10 == 0 and price != 0 or price % 10 == r:
		break
	cost = cost + 1
	price = price + k
print(cost)


(x, y) = map(int, input().split())
w = 2
for q in range(1, 10000):
	w = (x * q - y) % 10
	r = x * q % 10
	if w == 0 or r == 0:
		print(q)
		quit()


(k, r) = [int(i) for i in input().split()]
res = 1
while True:
	aux = k * res
	mod = aux % 10
	if mod != 0 and mod != r:
		res += 1
	else:
		break
print(str(res))


(n, r) = map(int, input().split())
for i in range(1, 200):
	if i * n % 10 == r or i * n % 10 == 0:
		print(i)
		break


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 msi():
	return map(str, input().strip().split(' '))

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

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 // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
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 factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(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()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	(k, r) = read()
	c = 1
	while True:
		val = c * k
		if val % 10 == 0 or val % 10 == r:
			break
		c += 1
	print(c)
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')
for i in range(1):
	solve()


(price, coin) = map(int, input().split())
for i in range(1, 1001):
	if price * i % 10 == 0 or price * i % 10 == coin:
		print(i)
		break


a = list(map(int, input().split()))
n = 1
d = True
while d:
	if n * a[0] % 10 == 0 or (n * a[0] - a[1]) % 10 == 0:
		d = False
		print(n)
	n = n + 1


userInput = input()
userInput = userInput.split()
shovelPrice = int(userInput[0])
littelCoin = int(userInput[1])
shovelNum = 1
while shovelPrice * shovelNum % 10 != 0 and shovelPrice * shovelNum % 10 != littelCoin:
	shovelNum += 1
print(shovelNum)


(k, r) = map(int, input().split())
for i in range(9):
	if k * (i + 1) % 10 == 0 or k * (i + 1) % 10 == r:
		print(i + 1)
		break
	else:
		pass


(k, r) = input().split()
k = int(k)
r = int(r)
s = 0
i = 0
while True:
	i += 1
	s = k * i
	if (s - r) % 10 == 0:
		break
	elif s % 10 == 0:
		break
print(i)


(k, r) = map(int, input().split())
x = 1
while True:
	if (k * x - r) % 10 != 0 and k * x % 10 != 0:
		x = x + 1
	else:
		break
print(x)


(k, r) = map(int, input().split())
i = 1
while True:
	price = k * i
	if price % 10 == 0:
		print(i)
		break
	elif (price - r) % 10 == 0:
		print(i)
		break
	i += 1


I = lambda : map(int, input().split())
(k, r) = I()
i = 1
while True:
	if (i * (k % 10) - r) % 10 == 0 or i * (k % 10) % 10 == 0:
		break
	i += 1
print(i)


(k, r) = map(int, input().split())
shovel = k
for i in range(shovel * 1000):
	if shovel % 10 == 0 or (shovel - r) % 10 == 0:
		break
	else:
		shovel += k
print(i + 1)


(p, r) = map(int, input().split())
p1 = p
i = 1
while True:
	if p % 10 == 0 or p % 10 == r:
		print(i)
		break
	else:
		i += 1
		p = p1 * i


(k, r) = map(int, input().split())
b = True
i = 0
h = 1
while b:
	i += 1
	h = k * i
	if h % 10 == 0 or h % 10 == r:
		b = False
print(i)


(k, r) = map(int, input().split())
ans = 1
while (ans * k - r) % 10 and ans * k % 10:
	ans += 1
print(ans)


(k, r) = map(int, input().split())
n = 1
while n > 0:
	s = n * k
	if (s - r) % 10 == 0 or s % 10 == 0:
		print(n)
		break
	n += 1


s = list(map(int, input().split()))
n = s[0]
k = s[1]
c = 1
boolean = True
while boolean:
	if n * c % 10 == 0:
		print(c)
		break
	if n * c % 10 == k:
		print(c)
		break
	else:
		c += 1


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


(n, m) = list(map(int, input().split()))
tod = n
tam = 2
p = 1
for x in range(555555):
	if n % 10 == 0 or (n - m) % 10 == 0:
		print(p)
		break
	else:
		n = tod * tam
		tam += 1
		p += 1


(k, r) = map(int, input().split())
(c, a) = (1, 1)
while 1:
	if a * k % 10 == r or a * k % 10 == 0:
		print(c)
		break
	c += 1
	a += 1


B = 10
(k, r) = map(int, input().split())
for i in range(1, 11):
	j = i * k % B
	if 1 > j or j == r:
		break
print(i)


(n, k) = map(int, input().split())
i = 0
f = n
while n % 10 != 0 and n % 10 != k:
	i += 1
	n += f
print(i + 1)


(k1, r) = map(int, input().split())
cnt = 0
k = k1
while k % 10 != r:
	if k % 10 == 0:
		break
	k += k1
	cnt += 1
print(1 + cnt)


(x, y) = input().split(' ')
x = x[-1]
add = int(x[-1])
count = 1
while x != y and x != '0':
	x = str(int(x) + add)
	x = x[-1]
	count += 1
print(count)


array_of_values = input().split(' ')
for x in range(1, 11):
	if int(array_of_values[0]) * x % 10 == 0 or int(array_of_values[0]) * x % 10 == int(array_of_values[1]):
		print(x)
		break


(p, r) = [int(i) for i in input().split()]
for i in range(1, 21):
	if p * i % 10 == 0 or p * i % 10 == r:
		print(i)
		break


(n1, n) = map(int, input().split())
i = 1
while 1:
	if (n1 * i - n) % 10 == 0 or n1 * i % 10 == 0:
		print(i)
		break
	i += 1


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


def main():
	(k, r) = map(int, input().split())
	s = k
	c = 1
	while True:
		if s % 10 == 0 or s % 10 == r:
			break
		s += k
		c += 1
	print(c)
main()


(K, R) = [int(x) for x in input().split()]
for i in range(1, 10):
	if i * K % 10 == 0:
		print(i)
		break
	elif (i * K - R) % 10 == 0:
		print(i)
		break
	else:
		i += 1


from collections import defaultdict
import sys, os, math
(k, r) = map(int, input().split())
for i in range(1, 11):
	if i * k % 10 == r or i * k % 10 == 0:
		print(i)
		sys.exit(0)


(n, m) = input().split()
n = int(n)
m = int(m)
i = 0
while True:
	i += 1
	if n * i % 10 == 0 or n * i % 10 == m:
		break
print(i)


(k, r) = map(int, input().split())
i = 1
c = 0
while i:
	n = i * k
	q = n // 10
	a = q * 10
	a = n - a
	c = c + 1
	if a == r or n % 10 == 0:
		break
	i = i + 1
print(c)


(k, r) = map(int, input().split())
s = k
ans = 1
while s % 10 != 0 and (s - r) % 10 != 0:
	ans += 1
	s += k
	if ans > 10:
		break
print(ans)


(k, r) = map(int, input().split())
su = 1
while True:
	if k * su % 10 == r or k * su % 10 == 0:
		print(su)
		break
	else:
		su += 1


(k, r) = map(int, input().split())
x = 1
while True:
	if (k * x - r) % 10 == 0 or k * x % 10 == 0:
		print(x)
		break
	x += 1


inputs = list(map(int, input().split()))
priceOfShovel = inputs[0]
coins = inputs[1]
mod = priceOfShovel % 10
for i in range(1, 1000):
	total = priceOfShovel * i
	if total % 10 == 0 or total % 10 == coins:
		print(i)
		break


(p, c) = map(int, input().split())
counter = 1
while True:
	if p * counter % 10 == 0 or p * counter % 10 == c:
		print(counter)
		break
	counter += 1


isDebug = False
(k, r) = [int(x) for x in input().split()]
c = 1
s = k
while s % 10 != 0 and (s - r) % 10 != 0:
	print(f'--------------') if isDebug else ''
	print(f's={s}, c={c}') if isDebug else ''
	print(f's%10={s % 10}, (s-r)%10={(s - r) % 10}') if isDebug else ''
	s = s + k
	c = c + 1
print(f'{c}')


plyc = input().split()
k = int(plyc[0])
r = int(plyc[1])
shvl = 1
ls = ['1']
prc = 1.2
while prc % 10 != 0 and (prc - r) % 10 != 0:
	prc = shvl * k
	ls.clear()
	ls.append(shvl)
	shvl += 1
print(ls[0])


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
for t in range(0, test):
	(n, k) = list(map(int, input().strip().split()))
	for i in range(1, 11):
		temp = n * i
		if temp % 10 == 0 or temp % 10 == k:
			ans = i
			break
	print(ans)
	ans = solve()


(k, r) = input().split()
(k, r) = (int(k), int(r))
ans = 0
for i in range(1, 10):
	if i * k % 10 == 0 or i * k % 10 == r:
		ans = i
		break
print(ans)


(k, r) = map(int, input().strip().split())
s = 0
for i in range(1, 10):
	s = k * i
	if s % 10 == r or s % 10 == 0:
		print(i)
		break


listy = input().split()
listy = [int(x) for x in listy]
k = listy[0]
r = listy[1]
mini = 1
xxx = -1
while xxx != r and xxx != 0:
	xxx = mini * k % 10
	mini += 1
print(mini - 1)


n = list(map(int, input().split()))
for i in range(1, 10):
	if i * n[0] % 10 == 0 or i * n[0] % 10 == n[1]:
		print(i)
		break


(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
a = a % 10
i = 1
c = 1
x = a
while i < 10:
	p = a * i
	if p % 10 == b or p % 10 == 0:
		print(c)
		break
	else:
		i += 1
		c += 1


(k, r) = map(int, input().split())
ld = k % 10
n = 1
while True:
	if n * ld % 10 == r or k * n % 10 == 0:
		break
	else:
		n += 1
print(n)


(k, r) = list(map(int, input().split()))
ans = 10
for x in range(1, 11):
	mod = k * x % 10
	if mod == 0 or mod == r:
		ans = x
		break
print(ans)


(a, b) = map(int, input().split())
c = True
count = 0
A = a
while c:
	if a % 10 - b == 0 or a % 10 == 0:
		count += 1
		print(count)
		c = not c
	count += 1
	a += A


(n, k) = map(int, input().split())
m = n
i = 2
while n >= 1:
	if n % 10 == 0:
		l = n // m
		break
	elif n % 10 == k:
		l = n // m
		break
	else:
		n = m * i
		i = i + 1
print(l)


from itertools import product, combinations
from math import sqrt
(k, r) = map(int, input().split())
k %= 10
if k == 0:
	print(1)
else:
	i = 1
	while k * i % 10 != r and k * i % 10 != 0:
		i += 1
	print(i)


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


(k, r) = [int(x) for x in input().split()]
a = k % 10
if a == 0:
	print(1)
elif a == 1:
	print(r)
elif a == 2:
	if r % 2 == 1:
		print(5)
	else:
		print(r // 2)
elif a == 3:
	k = [7, 4, 1, 8, 5, 2, 9, 6, 3]
	print(k[r - 1])
elif a == 4:
	if r % 2 == 1:
		print(5)
	else:
		k = [3, 1, 4, 2]
		print(k[r // 2 - 1])
elif a == 5:
	if r == 5:
		print(1)
	else:
		print(2)
elif a == 6:
	if r % 2 == 1:
		print(5)
	else:
		k = [2, 4, 1, 3]
		print(k[r // 2 - 1])
elif a == 7:
	k = [3, 6, 9, 2, 5, 8, 1, 4, 7]
	print(k[r - 1])
elif a == 8:
	if r % 2 == 1:
		print(5)
	else:
		k = [4, 3, 2, 1]
		print(k[r // 2 - 1])
elif a == 9:
	k = [9, 8, 7, 6, 5, 4, 3, 2, 1]
	print(k[r - 1])


(n, k) = map(int, input().split())
i = 1
cnt = 0
max = 9
sum = 0
for x in range(0, max):
	sum = n * i
	cnt += 1
	if sum % 10 == 0 or (sum - k) % 10 == 0:
		print(cnt)
		break
	i += 1


(n, k) = map(int, input().split())
count = 0
b = True
h = 1
while b:
	count += 1
	h = n * count
	if h % 10 == 0 or h % 10 == k:
		b = False
print(count)


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


(k, r) = map(int, input().split())
ans = 1
n = k
while n % 10 != r:
	if n % 10 == 0:
		break
	n += k
	ans += 1
print(ans)


p = input()
p = p.split()
r = int(p[1])
p = int(p[0])
i = 1
while 1:
	if (p * i - r) % 10 == 0 or p * i % 10 == 0:
		print(i)
		break
	i += 1


t = list(map(int, input().split()))
n = 1
while True:
	change = t[0] * n % 10
	if not change or change == t[1]:
		print(n)
		break
	else:
		n += 1


(k, r) = list(map(int, input().split()))
i = 1
while True:
	m = (i * k - r) / 10.0
	n = i * k / 10.0
	if m.is_integer() or n.is_integer():
		break
	i += 1
print(i)


lt = list(input().split())
price = int(lt[0])
coin = int(lt[1])
lt = []
if coin % price == 0:
	lt.append(coin // price)
if price % 2 == 0:
	lt.append(5)
if price % 5 == 0:
	lt.append(2)
if price % 10 == 0 or (price - coin) % 10 == 0:
	lt.append(1)
else:
	lc = 0
	tot = coin
	while lc < 1001 and tot % price != 0:
		tot += 10
		lc += 1
	lt.append(int(tot / price))
a = sorted(lt)[0]
print(a)


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


(shovel_cost, coin_denomination) = map(int, input().split())
num_shovels = 1
while True:
	total_cost = shovel_cost * num_shovels
	remainder = total_cost % 10
	if remainder == 0 or remainder == coin_denomination:
		break
	num_shovels += 1
print(num_shovels)


import sys

def MCD(a, b):
	if a % b == 0:
		return b
	return MCD(b, a % b)
(k, r) = [int(x) for x in sys.stdin.readline().replace('\n', '').split(' ')]
ans = 11
for i in range(1, 10):
	if k * i % 10 == 0 and i < ans:
		ans = i
	elif k * i % 10 - r == 0 and i + 1 < ans:
		ans = i
sys.stdout.write(str(ans))


(k, r) = map(int, input().split())
count = 1
t = k
while 1:
	if t % 10 == r or t % 10 == 0:
		break
	count += 1
	t += k
print(count)


(k, r) = [int(x) for x in input().split()]
num = 1
if r % k == 0:
	print(int(r / k))
elif k % 10 == 0:
	print(1)
else:
	while num < 10 and num * k % 10 != r and (num * k % 10 != 0):
		num = num + 1
	else:
		if num < 10 and num * k % 10 == r and (num * k % 10 != 0):
			print(num)
		elif num < 10 and num * k % 10 != r and (num * k % 10 == 0):
			print(num)
		else:
			print(10)


inp = [int(x) for x in input().split()]
for i in range(1, 1000):
	if i * inp[0] % 10 == inp[1]:
		print(i)
		break
	elif i * inp[0] % 10 == 0:
		print(i)
		break


(k, r) = map(int, input().split())
res = 0
n = 0
while True:
	res += k
	n += 1
	if str(res)[-1] == '0' or str(res)[-1] == str(r):
		print(n)
		break


(x, y) = input().split()
(x, y) = (int(x), int(y))
i = 1
while True:
	if x * i % 10 == y or x * i % 10 == 0:
		print(i)
		break
	else:
		i += 1


(k, r) = map(int, input().split())
if k % 10 == r:
	print(1)
else:
	coun = 0
	temp = k
	while k % 10 != r and k % 10 != 0:
		coun = coun + 1
		k = temp * (coun + 1)
	print(coun + 1)


(k, r) = [int(x) for x in input().split()]
flag = 0
for i in range(1, 10):
	if k * i % 10 == 0 or (k * i - r) % 10 == 0:
		flag = 1
		break
if flag == 0:
	print('10')
else:
	print(i)


(k, r) = map(int, input().split())
it = k
result = 1
while it % 10 != r and it % 10 != 0:
	it += k
	result += 1
print(result)


(a, b) = input().split()
(a, b) = (int(a), int(b))
count = 1
while count < 10:
	if a * count % 10 == 0 or a * count % 10 == b:
		print(count)
		break
	count += 1


(k, r) = map(int, input().split())
if k % 5 == 0 and r == 5:
	print(1)
elif k % 10 == 0:
	print(1)
elif k % 5 == 0:
	print(2)
else:
	for i in range(1, 11):
		if k * i % 10 == 0:
			print(i)
			break
		elif (k * i - r) % 10 == 0:
			print(i)
			break


(pric, coin) = map(int, input().split())
ogpric = int(pric)
x = int(0)
while x == 0:
	if pric % 10 == 0 or pric % 10 == coin:
		x = 1
	else:
		pric = pric + ogpric
if pric % 10 == 0:
	print(pric // ogpric)
if pric % 10 == coin:
	print(pric // ogpric)


(k, r) = map(int, input().split())
for i in range(k):
	if (10 * i % k == 0 or (10 * i + r) % k == 0) and i != 0 or r % k == 0:
		break
if (10 * i + r) % k == 0:
	print(int((10 * i + r) / k))
else:
	print(int(10 * i / k))


(k, r) = map(int, input().split())
l = 1
cena = k
while True:
	if k % 10 == r or k % 10 == 0:
		break
	l += 1
	k = l * cena
print(l)


(k, r) = map(int, input().split())
i = 1
while 1:
	if k * i % 10 == r or k * i % 10 == 0:
		print(i)
		exit(0)
	i += 1


sh = 1
mul = 1
(n, k) = map(int, input().split())
n = num = n % 10
while not (n % 10 == 0 or (n - k) % 10 == 0):
	mul += 1
	n = num * mul
	sh += 1
print(sh)


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


(k, r) = map(int, input().split())

def f(s):
	if k < 10 and k == r:
		return 1
	elif s * k % 10 == 0 or s * k % 10 == r:
		return s
	else:
		return f(s + 1)
print(f(1))


(k, r) = (int(j) for j in input().split())
n = 1
f = k % 10
while k % 10 != r and k % 10 != 0:
	k = f
	n += 1
	k *= n
print(n)


(k, r) = map(int, input().split())
flag = 1
x = 0
while flag:
	x += 1
	if k * x % 10 == 0 or k * x % 10 == r:
		flag = 0
print(x)


def main():
	(k, r) = input().split()
	k = int(k)
	r = int(r)
	for i in range(1, 10):
		if (k * i - r) % 10 == 0 or k * i % 10 == 0:
			print(i)
			return ()
	print('10')
main()


(org_price, r) = map(int, input().split())
i = 1
while True:
	price = i * org_price
	rem = price % 10
	if rem == r or rem == 0:
		print(i)
		break
	i += 1


(price, change) = [int(x) for x in input().split(' ')]
initial = price
amt = 0
while True:
	if int(str(price)[-1]) == change:
		amt += 1
		print(amt)
		break
	elif price % 10 == 0:
		amt += 1
		print(amt)
		break
	else:
		amt += 1
		price += initial


(k, r) = map(int, input().split())
count = 1
while r != k * count % 10 != 0:
	count += 1
print(count)


def main():
	(k, r) = tuple(map(int, input().rstrip().split()))
	x = 1
	while k * x % 10 not in (0, r):
		x += 1
	print(x)
main()


(k, r) = list(map(int, input().split(' ')))
count = 1
while True:
	if k * count % 10 == 0 or (k * count - r) % 10 == 0:
		break
	else:
		count += 1
print(count)


(k, r) = map(int, input().split())
i = 1
while True:
	a = k * i
	if str(a)[-1] == '0':
		print(i)
		break
	elif str(a - r)[-1] == '0':
		print(i)
		break
	i += 1


(a, c) = map(str, input().split())
if a[-1] == c:
	print(1)
elif a[-1] == '0':
	print(1)
elif a[-1] == '5':
	print(2)
else:
	a = int(a)
	for i in range(2, 10):
		y = str(a * i)
		if y[-1] == c:
			print(i)
			break
		if y[-1] == '0':
			print(i)
			break


(k, r) = input().strip().split()
(k, r) = (int(k), int(r))
shovels = 0
paid = 0
count = 0
while (paid - r) % 10 != 0:
	if paid % 10 == 0 and count > 0:
		break
	else:
		paid += k
		shovels += 1
		count += 1
print(shovels)


(k, r) = map(int, input().split())
count = 0
for i in range(1, 1000000000):
	k1 = k * i
	if k1 % 10 == 0:
		count += 1
		break
	else:
		z = k1 // 10
		diff = k1 - 10 * z
		count += 1
		if diff == r:
			break
print(count)


(k, r) = map(int, input().split())
l = 0
for i in range(k, 10000000, k):
	l = l + 1
	if i % 10 == 0 or (i - r) % 10 == 0:
		print(l)
		break


def main():
	(k, r) = input().split(' ')
	shovelPrice = int(k)
	burles = int(r)
	i = 1
	while True:
		if shovelPrice % 10 == 0:
			break
		elif (shovelPrice - burles) % 10 == 0:
			break
		else:
			shovelPrice = int(k) * i
			if (shovelPrice - burles) % 10 == 0 or shovelPrice % 10 == 0:
				break
			i += 1
	print(i)
main()


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


(k, r) = map(int, input().split())
c = 0
u = k
while True:
	c += 1
	if k % 10 == 0 or k % 10 == r:
		print(c)
		break
	k += u


(p, d) = map(int, input().split())
for i in range(1, 10):
	s = p * i
	rem = s % 10
	if rem == d or rem == 0:
		print(i)
		break


(k, r) = [int(i) for i in input().split()]
numOfShovels = 1
while numOfShovels * k % 10 != r:
	if numOfShovels * k % 10 == 0:
		break
	numOfShovels += 1
print(numOfShovels)


l = list(map(int, input().split()))
for i in range(1, 10):
	if (l[0] * i - l[1]) % 10 == 0 or l[0] * i % 10 == 0:
		ans = i
		print(ans)
		break


p = input()
p = p.split()
k = int(p[0])
r = int(p[1])
i = 1
while k > 0:
	p = k * i
	if p % 10 == 0:
		break
	else:
		p = p - r
		if p % 10 == 0:
			break
		else:
			i = i + 1
if i > 10:
	i = 10
print(i)


(n, m) = map(int, input().split())
flag = 1
i = 1
while 0 != n * i % 10 != m:
	i += 1
print(i)


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


(k, r) = map(int, input().split())
ans = 0
for i in range(1, 11):
	price = i * k
	if str(price)[-1] == '0' or str(price)[-1] == str(r):
		print(i)
		break


(k, r) = map(int, input().split(' '))
p = {0, r}
i = 1
while True:
	mod = i * k % 10
	if mod in p:
		print(i)
		break
	else:
		i += 1


n = input().split(' ')
k = int(n[0])
r = int(n[1])
for i in range(2, 10):
	if k % 10 == 0 or k % 10 == r:
		print('1')
		break
	elif k * i % 10 == 0 or k * i % 10 == r:
		print(i)
		break
	else:
		continue


(k, r) = [int(x) for x in input().split()]
shovels = 1
while k * shovels % 10 and (k * shovels - r) % 10:
	shovels += 1
print(shovels)


def Main():
	(k, r) = map(int, input().split())
	for i in range(1, 10):
		if i * k % 10 == 0 or i * k % 10 == r:
			print(i)
			k = -1
			break
	if k != -1:
		print(10)
Main()


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


import math
(rate, change) = map(int, input().split())
last_digit = rate % 10
if last_digit == 0:
	print('1')
	exit()
for i in range(1, 11):
	if i * last_digit % 10 == change:
		print(i)
		break
else:
	lcm = last_digit * 10 // math.gcd(last_digit, 10)
	print(lcm // last_digit)


__author__ = 'Think'
(k, r) = [int(i) for i in input().split()]
k = k % 10
final = 0
total = 0
while True:
	total += 1
	final += k
	if final % 10 in [0, r]:
		print(total)
		break


(k, r) = map(int, input().split())
count = 1
z = [r, 0]
while k * count % 10 not in z:
	count = count + 1
print(count)


x = input().split(' ')
p = int(x[0])
o = int(x[1])
i = 1
while True:
	res = i * p
	res = str(res)
	res = list(res)
	res.reverse()
	if res[0] == '0' or res[0] == str(o):
		break
	else:
		i += 1
print(i)


(k, r) = map(int, input().split())
c = 1
d = k
while k % 10 != 0 and k % 10 != r:
	k += d
	c += 1
print(c)


(a, b) = map(int, input().split(' '))
i = 1
flag = True
while a * i % 10 != 0:
	if a * i % 10 - b == 0:
		print(i)
		flag = False
		break
	i += 1
if flag:
	print(i)


(price, r) = [int(i) for i in input().split(' ')]
Price = price
n = 1
while True:
	if price % 10 == 0 or price % 10 == r:
		print(n)
		break
	n += 1
	price = Price * n


(k, r) = map(int, input().split())
for i in range(10):
	price = k * (i + 1)
	if (price % 10 == 0) | (price % 10 == r):
		break
print(i + 1)


(k, r) = input().split(' ')
(k, r) = (int(k), int(r))
total = 0
shovels = 0
for i in range(10):
	total += k
	shovels += 1
	if total % 10 == 0 or (total - r) % 10 == 0:
		break
print(shovels)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

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

def main():
	q = ain()
	k = q[0]
	r = q[1]
	for i in range(1, 10):
		if float((k * i - r) / 10).is_integer() or float(k * i / 10).is_integer():
			print(i)
			break
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


sum = 1
i = 0
(k, r) = map(int, input().split())
var = True
while var:
	i += 1
	sum = k * i
	if sum % 10 == 0 or sum % 10 == r:
		var = False
print(i)


nums = list(map(int, input().split()))
k = nums[0]
r = nums[1]
l = list(range(1, 10))
position = 0
while position < len(l):
	i = l[position]
	if k * i % 10 == 0:
		print(i)
		break
	elif k * i % 10 == r:
		print(i)
		break
	position += 1
else:
	pass


(k, r) = map(int, input().strip().split(' '))
q = 1
while True:
	res = k * q
	if res == r:
		break
	elif res != r and res < 10:
		q += 1
	elif res % 10 == 0 or res % 10 - r == 0:
		break
	else:
		q += 1
print(q)


from sys import stdin

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

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

def linput():
	return list(map(int, stdin.readline().split()))
(k, r) = minput()
for i in range(1, 11):
	if k * i % 10 == 0 or k * i % 10 == r:
		print(i)
		break


(k, r) = map(int, input().split())
i = 0
while 1:
	i += 1
	p = k * i
	l = list(str(p))
	x = int(l[-1])
	if x == r or x == 0:
		break
print(i)


(k, r) = input().split()
k = int(k)
total = str(k)
count = 1
while str(total)[-1] != r:
	total = int(total)
	if total % 10 == 0:
		break
	total += k
	count += 1
print(count)


(k, r) = map(int, input().split())
flag = 0
ans = float('inf')
for i in range(1, 11):
	if i * k % 10 == r:
		flag = 1
		ans = i
		break
	elif i * k % 10 == 0:
		flag = 1
		ans = i
		break
if flag == 0:
	print(10)
else:
	print(ans)


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


(n, a) = input().split()
n = int(n)
a = int(a)
sum = 0
i = 1
while i:
	if i * n % 10 == 0 or i * n % 10 == a:
		print(i)
		break
	i += 1


(k, r) = map(int, input().split())
i = 1
while 0 != k * i % 10 != r:
	i = i + 1
print(i)


(a, b) = [int(i) for i in input().split()]
cnt = 0
j = 1
while True:
	k = a * j
	if k % 10 == 0:
		break
	elif k % 10 / b == 1:
		break
	else:
		cnt += 1
		j += 1
print(cnt + 1)


A = input().split()
i = 1
while i * int(A[0]) % 10 != int(A[1]) and i * int(A[0]) % 10 != 0:
	i += 1
print(i)


(k, r) = map(int, input().split())
otvet = 1
while otvet * k % 10 != r:
	if otvet * k % 10 == 0:
		print(otvet)
		break
	otvet += 1
else:
	print(otvet)


(k, r) = list(map(int, input().split()))
for i in range(1, 10):
	d = k * i
	if d % 10 == 0 or d % 10 - r == 0:
		print(i)
		break


(k, r) = list(map(int, input().split()))
i = 1
while (int(str(k * i)[-1]) != r and int(str(k * i)[-1]) != 0) and i < 10:
	i += 1
print(i)


(n, k) = map(int, input().split())
u = n % 10
if u == k:
	print(1)
else:
	for i in range(1, 10):
		x = i * u % 10
		if x == 0 or x == k:
			print(i)
			break


(a, b) = list(map(int, input().split()))
i = 0
while 1:
	if (10 * i + b) % a == 0:
		sum1 = 10 * i + b
		break
	if 10 * i % a == 0 and i != 0:
		sum1 = 10 * i
		break
	i += 1
print(sum1 // a)


(k, r) = input().split(' ')
k = int(k)
r = int(r)
number = 1
change = 0
while True:
	change = k * number % 10
	if change != 0:
		change -= r
		if change != 0:
			number += 1
	if change == 0:
		break
print(number)


(k, r) = map(int, input().split())
if k % 10 == 0:
	print(1)
elif k % 10 == 5 and r != 5:
	print(2)
elif k == 5 and r == 5:
	print(1)
else:
	a = k
	i = 1
	while i > 0:
		if k % 10 == r:
			break
		if k % 10 == 0:
			break
		if k % 10 != r:
			k = k + a
		i = i + 1
	print(i)


(a, b) = input().split()
a = int(a)
b = int(b)
sum = a
k = 1
while k <= 1000:
	if sum % 10 == b or sum % 10 == 0:
		print(k)
		break
	k += 1
	sum += a


(k, r) = map(int, input().split())
cnt = 0
if k == r:
	print(1)
else:
	i = 1
	while 1:
		total = k * i
		cnt += 1
		if total % 10 == 0:
			break
		if (total - r) % 10 == 0:
			break
		i += 1
		total = k * i
	print(cnt)


def shovel(k, r):
	count = 1
	cost = 0
	while True:
		cost = k * count
		if cost % 10 == r or cost % 10 == 0:
			return count
		count += 1
x = list(map(int, input().rstrip().split()))
k = x[0]
r = x[1]
print(shovel(k, r))


(price, k) = map(int, input().split())
counter = 1
amount = price
while amount % 10 != k and amount % 10 != 0:
	amount += price
	counter += 1
print(counter)


def main():
	l = list()
	l = input()
	l = l.split()
	p = int(l[0])
	n = int(l[1])
	i = 1
	while i * p % 10 != n and i * p % 10 != 0:
		i += 1
	print(i)
main()


(cost, r) = map(int, input().split())
for i in range(1, 1001):
	if cost * i % 10 in [0, r]:
		print(i)
		exit()


def solve(r, k):
	d = r % 10
	for i in range(1, 11):
		if r * i % 10 == k or r * i % 10 == 0:
			return i
	return 10
(r, k) = tuple(map(int, input().split()))
print(solve(r, k))


data = input().split()
price = int(data[0])
i = 1
while True:
	data[0] = price
	data[0] = data[0] * i
	if data[0] % 10 == 0 or data[0] % 10 == int(data[1]):
		break
	else:
		i = i + 1
print(i)


def main():
	[k, r] = [int(_) for _ in input().split()]
	for i in range(1, 11):
		if k * i % 10 == 0 or k * i % 10 == r:
			print(i)
			break
main()


def solve():
	(k, r) = [int(s) for s in input().split()]
	k2 = k
	ans = 1
	while k % 10 != r and k % 10 != 0:
		k += k2
		ans += 1
	print(ans)
solve()


(price, r) = map(int, input().split())
n = 0
val = price
while True:
	n += 1
	if int(str(price)[-1]) == r:
		break
	if int(str(price)[-1]) == 0:
		break
	else:
		price += val
print(n)


show = 1
mu = 1
(n, k) = map(int, input().split())
n = num = n % 10
while not (n % 10 == 0 or (n - k) % 10 == 0):
	mu += 1
	n = num * mu
	show += 1
print(show)


(k, r) = list(map(int, input().split()))
sum = 0
while 1:
	sum += k
	if sum % 10 == 0 or sum % 10 == r:
		break
print(sum // k)


n = input()
(k, r) = n.split(' ')
num_shovel = 1
while True:
	total = num_shovel * int(k)
	if total % 10 == 0 or total % 10 == int(r):
		break
	else:
		num_shovel += 1
print(num_shovel)


(k, r) = [int(a) for a in input().split(' ')]
ans = 0
flag = True
new_k = k
while flag:
	ans += 1
	rem = new_k % 10
	if rem == r or rem == 0:
		flag = False
		print(ans)
	else:
		new_k += k


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


k_r = list(map(int, input().split(' ')))
(k, r) = k_r
n = 1
while k * n % 10 != 0 and k * n % 10 != r:
	n += 1
print(n)


import sys
(k, r) = map(int, sys.stdin.readline().split())
shovels = 0
while True:
	shovels += 1
	pay = shovels * k
	if pay // 10 * 10 == pay or pay // 10 * 10 + r == pay:
		print(shovels)
		break


(k, r) = map(int, input().split())
count = 1
inc = k
i = 2
while k % 10 != r and k % 10 != 0:
	k = inc * i
	count += 1
	i += 1
print(count)


(k, r) = input().split()
k = int(k)
r = int(r)
d = []
for i in range(0, 10000):
	if (k * i - r) % 10 == 0:
		d.append(i)
		print(i)
		break
if d == []:
	for j in range(1, 10000):
		if j * k % 10 == 0:
			print(j)
			break


a = [10, 5, 10, 5, 2, 5, 10, 5, 10]
(k, r) = map(int, input().split(' '))
p = int(str(k)[-1])
if p == 0:
	print('1')
elif p == r:
	print('1')
else:
	flag2 = 0
	flag1 = a[p - 1]
	for i in range(1, 11):
		if int(str(p * i)[-1]) == r:
			flag2 = i
			break
	if flag2 == 0:
		print(flag1)
	elif flag2 <= flag1:
		print(flag2)
	else:
		print(flag1)


import math
(k, r) = map(int, input().split())
ans = 1
while ans * k % 10 != 0 and ans * k % 10 != r:
	ans = ans + 1
print(ans)


(n, k) = map(int, input().split())
ans = 1
while n * ans % 10 != k and n * ans % 10:
	ans += 1
print(ans)


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


(m, n) = map(int, input().split())
c = 0
i = 1
while 1:
	v = m * i
	c = c = +1
	if v % 10 == 0 or v % 10 == n:
		break
	i = i + 1
if c == 0:
	print(10)
else:
	print(i)


q = list(map(int, (x for x in input().split() if x.isdigit())))
w = 'yes'
i = 1
while w == 'yes':
	y = i * q[0]
	if y % 10 == 0 or (y - q[1]) % 10 == 0:
		w = 'no'
		break
	else:
		i += 1
print(i)


(k, r) = [int(x) for x in input().split()]
for m in range(1, 101):
	n = m * k % 10
	breakpoint = 0
	if n == 0 or n == r:
		print(m)
		breakpoint = 1
	if breakpoint == 1:
		break


(a, b) = map(int, input().split())
i = 1
f = 0
while f == 0:
	n = i * a
	if n % 10 == b or n % 10 == 0:
		print(i)
		f = 1
	else:
		i += 1


arr = list(map(int, input().split()))
cost = arr[0]
r = arr[1]
i = 1
while True:
	temp = i * cost % 10
	if temp == r or temp == 0:
		break
	i += 1
print(i)


from sys import stdin
(k, r) = map(int, input().strip().split())
for i in range(1, 11):
	if (k * i - r) % 10 == 0 or k * i % 10 == 0:
		print(i)
		break


(k, r) = map(int, input().split())
i = 1
while k * i % 10 != r and k * i % 10 != 0:
	i += 1
if k * i % 10 == 0:
	print(i)
else:
	print(i)


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


(p, r) = [int(x) for x in input().split()]
i = 1
t = 0
while True:
	if p * i % 10 == 0:
		t = i
		break
	if (p * i - r) % 10 == 0:
		t = i
		break
	i += 1
print(t)


(price, coin) = [int(i) for i in input().split()]
minimumShovels = 1
while True:
	priceOfShovels = price * minimumShovels
	if priceOfShovels % 10 == 0 or (priceOfShovels - coin) % 10 == 0:
		print(minimumShovels)
		break
	else:
		minimumShovels = minimumShovels + 1


(k, r) = [int(x) for x in input().split()]

def isGood(n):
	m = n % 10
	return m == 0 or m == r
ctr = 1
val = k
while not isGood(val):
	ctr += 1
	val = k * ctr
print(ctr)


(a, b) = (int(x) for x in input().split())
for i in range(1, 11):
	if i * a % 10 == 0 or i * a % 10 == b:
		print(i)
		exit()


(a, b) = map(int, input().split(' '))
su = 1
n = 0
k = a
while n < 20:
	if k % 10 - b == 0 or k % 10 == 0:
		break
	else:
		su += 1
		k = a * su
		n += 1
print(su)


(k, r) = map(int, input().split())
sum = 0
while sum % 10 != r:
	if k % 10 == 5 and r != 5:
		print(2)
		break
	if k % 10 == 0:
		print(1)
		break
	if sum % 10 == 0 and sum != 0:
		print(sum // k)
		break
	sum += k
	n = sum // k
else:
	print(n)


import sys
(k, r) = map(int, sys.stdin.readline().split())
k1 = k % 10
for i in range(1, 10):
	s = i * k1
	if s % 10 == 0 or (s - r) % 10 == 0:
		print(i)
		break
else:
	print(10)


(k, r) = map(int, input().split())
for i in range(1, 10):
	if not (i * k - r) % 10 or not i * k % 10 or k == r:
		break
print(i)


def shovel(k, r):
	count = 0
	sum = 0
	while True:
		sum += k
		count += 1
		if sum % 10 == 0 or sum % 10 == r:
			return count
kr = input().split()
k = int(kr[0])
r = int(kr[1])
print(shovel(k, r))


import sys
input = sys.stdin.readline

def main():
	i = inlt()
	price = i[0]
	coin = i[1]
	counter = 1
	while True:
		if price % 10 == coin or price % 10 == 0:
			print(counter)
			exit()
		price += i[0]
		counter += 1

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

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

def instr():
	return ''.join(insr())

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

def invr():
	return map(int, input().split())
main()


(n, k) = map(int, input().split())
for x in range(1, 10):
	if str(n * x)[-1] == str(k) or str(n * x)[-1] == '0':
		print(x)
		break


(k, r) = list(map(int, input().split()))
t1 = 0
t2 = 0
for i in range(0, k):
	t1 = t1 + 1
	if t1 * 10 % k == 0:
		break
for i in range(0, k):
	if (t2 * 10 + r) % k == 0:
		break
	t2 = t2 + 1
if t2 < t1:
	print((t2 * 10 + r) // k)
else:
	print(t1 * 10 // k)


(n, m) = map(int, input().split())
x = str(n)
p = q = int(x[-1])
c = 0
i = 1
while c == 0:
	if p == m or p == 0:
		print(i)
		break
	else:
		p += q
		p %= 10
	i += 1


(k, r) = [int(x) for x in input().split()]
shovels = 1
while not str(shovels * k).endswith(str(r)):
	if str(shovels * k).endswith('0'):
		break
	shovels += 1
print(shovels)


n = list(map(int, input().split()))
count = 1
while True:
	if (n[0] * count - n[1]) % 10 == 0 or n[0] * count % 10 == 0:
		break
	else:
		count += 1
print(count)


(n, k) = map(int, input().split())
nominal = 10
if n % 10 != 0:
	n = n % 10
	if n % 2 == 0 and k % 2 != 0:
		print(5)
	elif n == k:
		print(1)
	else:
		count = 0
		a = n
		while n % 10 != k and n % 10 != 0:
			count += 1
			n += a
		count += 1
		print(count)
elif n % 10 == 0:
	print(1)


inp = str(input()).split(' ')
price = int(inp[0][-1])
coin = int(inp[1])
counter = 1
while price * counter % 10 not in (0, coin):
	counter += 1
print(counter)


s = input().split(' ')
n = int(s[0])
k = int(s[1])
i = 1
while n * i % 10 != k and n * i % 10 != 0:
	i += 1
print(i)


(k, r) = map(int, input().split())
if str(k)[-1] == str(r) or str(k)[-1] == '0':
	print(1)
	exit()
for i in range(2, 11):
	s = str(k * i)[-1]
	if s == str(r) or s == '0':
		print(i)
		exit()


(a, b) = map(int, input().split())
i = 1
while True:
	if str(a * i)[-1] == str(b) or str(a * i)[-1] == '0':
		break
	i += 1
print(i)


(x, y) = map(int, input().split())
start = 0
a = 0
while True:
	if start % x == 0 and start != 0:
		a = 1
		break
	if (start + y) % x == 0:
		a = 2
		break
	start += 10
print(start // x if a == 1 else (start + y) // x)


(k, r) = map(int, input().split())
temp = 0
for i in range(1, 11):
	if k * i % 10 == r:
		print(i)
		temp = 1
		break
	elif k * i % 10 == 0:
		print(i)
		temp = 1
		break
if temp == 0:
	print(10)


(k, r) = map(int, input().split())
i = 1
while True:
	if k == r:
		print(1)
		break
	elif k <= r and r % k == 0:
		print(int(r / k))
		break
	if (i * k - r) % 10 == 0 or i * k % 10 == 0:
		print(i)
		break
	i += 1


(k, r) = map(int, input().split())
s = 1
while True:
	if k * s % 10 == 0 or (k * s - r) % 10 == 0:
		print(s)
		exit()
	s += 1


(k, r) = map(int, input().split())
z = 0
a = 1
while True:
	z = a * k
	if z % 10 == r or z % 10 == 0:
		print(a)
		break
	a += 1


from sys import stdin, stdout
from math import sqrt
inp = stdin.readline
out = stdout.write
(k, r) = map(int, inp().strip().split())
ld = int(str(k)[-1])
mn = 1000000.0
for i in range(1, 10):
	if str(ld * i)[-1] == '0' or str(ld * i)[-1] == str(r):
		mn = i
		break
print(mn)


(k, r) = map(int, input().split())
i = k
while i % 10 != r and i % 10 != 0:
	i += k
print(i // k)


(price, change) = input().split()
price = int(price)
change = int(change)
for i in range(1, 11):
	if price * i % 10 == 0 or price * i % 10 == change:
		print(i)
		break


(k, r) = map(int, input().split())
re = k % 10
if re == 0 or re == r:
	print(1)
else:
	c = 0
	i = 1
	while True:
		n = k * i
		re = n % 10
		c = c + 1
		if re == r or re == 0:
			break
		i = i + 1
	print(c)


(k, r) = [int(x) for x in input().split()]
for i in range(1, 11):
	if (i * k - r) / 10 == int((i * k - r) / 10) or i * k / 10 == int(i * k / 10):
		print(i)
		break


(m, n) = list(map(int, input().split()))
o = str(m)
if o[-1] == str(n):
	print(1)
elif o[-1] == '0':
	print(1)
else:
	i = 1
	while o[-1] != str(n) and o[-1] != '0':
		o = i * m
		o = str(o)
		i = i + 1
	print(i - 1)


(a, b) = list(map(int, input().split()))
(p, s) = (0, 0)
for i in range(1, 10000):
	o = a * i
	if o % 10 == 0:
		print(i)
		s += 1
		break
	else:
		t = o // 10
		u = o % 10
		p += 1
	if u == b:
		break
if s == 0:
	print(p)


(k, r) = input().split()
count = 1
while 1:
	if (count * int(k) - int(r)) % 10 == 0:
		print(count)
		break
	elif count * int(k) % 10 == 0:
		print(count)
		break
	else:
		count += 1


import sys, math, random
(n, m) = list(map(int, input().split()))
i = 1
while True:
	if i * n % 10 == m or i * n % 10 == 0:
		print(i)
		return
	i += 1


numbers = list(map(int, input().split()))
k = numbers[0]
r = numbers[1]
i = 1
while True:
	if k * i % 10 == r or k * i % 10 == 0 or k == r:
		break
	i += 1
print(i)


(a, b) = [int(i) for i in input().split(' ')]
c = a % 10
count = 1
while c * count % 10 != b and count < 10:
	count += 1
	if count == 10:
		c = -1
		break
if c == -1:
	if a % 10 == 0:
		print(1)
	elif a * 2 % 10 == 0:
		print(2)
	elif a * 5 % 10 == 0:
		print(5)
else:
	print(count)


inps = [int(a) for a in input().strip().split(' ')]
(k, r) = inps
count = 0
new = 0
if k % 10 == 0:
	print(1)
else:
	while True:
		count += 1
		new += k
		if new % 10 == r or new % 10 == 0:
			break
	print(count)


def main(args):
	entrada = list(map(int, input().split()))
	k = entrada[0]
	r = entrada[1]
	count = 1
	custo = k
	while True:
		if str(custo)[-1] == '0' or str(custo)[-1] == str(r):
			break
		custo += k
		count += 1
	print(count)
	return 0
import sys
sys.exit(main(sys.argv))


(k, r) = [int(x) for x in input().split()]
X = k
count = 1
while k % 10 != r and k % 10 != 0:
	count += 1
	k += X
print(count)


(a, b) = input().split()
(a, b) = (int(a), int(b))
sum = 1
while True:
	if a * sum % 10 == b or a * sum % 10 == 0:
		print(sum)
		break
	sum += 1


(n, k) = list(map(int, input().split()))
ans = 0
for i in range(1, 11):
	r = str(k)
	na = str(n * i)[-1]
	if r == na:
		print(i)
		break
	if n * i % 10 == 0:
		print(i)
		break


(l, m) = map(int, input().split())
c = 1
while l * c % 10 != m and l * c % 10:
	c += 1
print(c)


(k, r) = [int(i) for i in input().split()]
(ans, n) = (1, k % 10)
while n != r and n != 0:
	n = (n + k) % 10
	ans += 1
print(ans)


import sys
import math
import bisect

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


(k, r) = map(int, input().split())
start = 1
while (k * start - r) % 10 != 0 if k * start % 10 != 0 else k * start % 10 != 0:
	start += 1
print(start)


(price, coin) = list(map(int, input().split(' ')))
for i in range(1, 10):
	if price * i % 10 in [coin, 0]:
		print(i)
		break


(a, k) = list(map(int, input().split()))
c = a
n = k
i = False
while i == False:
	if (c - n) % 10 == 0:
		print(int(c / a))
		i = True
		break
	if c % 10 == 0:
		print(int(c / a))
		i = True
		break
	else:
		c += a


(k, r) = map(int, input().split())
found = False
shovels = 0
while not found and shovels < 10:
	shovels += 1
	if k * shovels % 10 == 0 or k * shovels % 10 == r:
		found = True
print(shovels)


(price, coin) = map(int, input().split())
n = 0
while True:
	n += 1
	if n * price % 10 == coin or n * price % 10 == 0:
		break
print(n)


(k, r) = [int(i) for i in input().split(' ')]
c = k
p = False
for i in range(10):
	if k * (i + 1) % 10 == r or k * (i + 1) % 10 == 0:
		c *= k
		print(i + 1)
		p = True
		break
	else:
		continue
if c == k and p == False:
	print(10)


(k, r) = [int(i) for i in input().split()]
i = 1
value = 0
while 1:
	value = value + k
	if value % 10 == 0 or (value - r) % 10 == 0:
		break
	else:
		i = i + 1
print(i)


line = input()
inp_list = line.split(' ')
a = int(inp_list[0])
b = int(inp_list[1])
flag = False
i = 0
while not flag:
	i += 1
	if a * i % 10 == b:
		flag = True
	elif a * i % 10 == 0:
		flag = True
print(i)


inp = input().split()
first_inp = int(inp[0])
c = 0
i = 2
y = True
while y:
	if int(inp[0]) % 10 != 0:
		if int(inp[1]) == int(inp[0]) % 10:
			c += 1
			y = False
		else:
			inp[0] = first_inp * i
			i += 1
			c += 1
	else:
		c += 1
		y = False
print(c)


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


def main():
	price = input()
	price = price.split()
	count = 1
	while 1:
		if int(price[0]) * count % 10 == 0 or int(price[0]) * count % 10 == int(price[1]):
			break
		else:
			count += 1
	print(count)
main()


s = input()
l = s.split(' ')
k = int(l[0])
r = int(l[1])
i = 1
while 1:
	p = i * k
	if p % 10 == 0 or p % 10 == r:
		break
	i += 1
print(i)


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


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


(k, r) = map(int, input().split())
num = k
counter = 1
while num % 10 not in [r, 0]:
	num += k
	counter += 1
print(counter)


(k, r) = map(int, input().split())
left = k % 10
num = 1
left1 = left
while True:
	if left1 == r or left1 == 0:
		print(num)
		break
	else:
		num += 1
		left1 = left * num % 10


(k, r) = [int(e) for e in input().split()]
for i in range(1, 11):
	m = k * i % 10
	if m == 0 or m == r:
		print(i)
		break


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(k, r) = map(int, input().split())
k %= 10
ans = 1
while True:
	cost = k * ans
	if cost % 10 == 0 or cost % 10 == r:
		print(ans)
		exit(0)
	ans += 1


(k, r) = [int(x) for x in input().split()]
i = 1
while k:
	if k * i % 10 == r or k * i % 10 == 0:
		k = 0
	else:
		i += 1
print(i)


def buyAShowel():
	values = input().split()
	count = 0
	while True:
		count += 1
		if int(values[0]) * count % 10 == int(values[1]) or int(values[0]) * count % 10 == 0:
			break
	print(count)
buyAShowel()


(n, k) = map(int, input().split(' '))
c = 0
for i in range(1, 10000):
	c += 1
	if i * n % 10 == 0:
		break
	elif i * n % 10 == k:
		break
print(c)


e = input().split(' ')
k = int(e[0])
r = int(e[-1])
g = k
ct = 0
while k % 10 != 0 and (k - r) % 10 != 0:
	k += g
	ct += 1
print(ct + 1)


(x, y) = [int(x) for x in input().split()]
cnt = 1
while (x * cnt - y) % 10 != 0 and x * cnt % 10 != 0:
	cnt += 1
print(cnt)


import sys
inf = float('inf')
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, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

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

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(k, r) = get_ints()
i = 1
count = 0
while k * i % 10 != r and k * i % 10 != 0:
	i += 1
	count += 1
print(count + 1)


(a, b) = map(int, input().split())
i = 1
z = []
r = 3
k = 0
if b == 3:
	r = 4
if a % 10 == 0:
	print('1')
else:
	while r != b:
		r = int(a * i % 10)
		i = i + 1
		if r == b:
			print(i - 1)
			break
		if r in z:
			k = 1
			break
		z.append(r)
	if a % 2 == 0 and k == 1:
		print('5')
	if a % 10 == 5 and b != 5:
		print('2')


(k, r) = map(int, input().split())
n = 1
flag = False
while flag == 0:
	if k * n % 10 != 0 and (k * n - r) % 10 != 0:
		n += 1
	else:
		print(n)
		flag = True


(k, r) = map(int, input().split())
p = k
n = 1
while p % 10 != 0 and (p - r) % 10 != 0:
	p += k
	n += 1
print(n)


(p, r) = map(int, input().split())
for k in range(1, 11):
	c = k * p % 10
	if c == 0 or c == r:
		print(k)
		break


kr = input().split()
k = int(kr[0])
r = int(kr[1])
counter = 0
if k % 10 == 0:
	print(1)
	counter = 1
else:
	for i in range(1, 10):
		if (i * k - r) % 10 == 0 or i * k % 10 == 0:
			print(i)
			counter = 1
			break
if counter == 0:
	print(10)


try:
	(k, r) = map(int, input().split())
	if k % 10 == 0 or k % 10 == r:
		print(1)
	elif k % 10 == 5:
		print(2)
	else:
		for i in range(2, 10):
			t = k * i
			if t % 10 == 0 or (t - r) % 10 == 0:
				print(i)
				break
except:
	pass


string = str(input())
arr = string.split()
k = int(arr[0])
r = int(arr[1])
count = 1
while True:
	if (count * k - r) % 10 == 0 or count * k % 10 == 0:
		break
	count += 1
print(count)


a = list(map(int, input().split()))
d = 0
for x in range(1, 1001):
	if a[0] * x % 10 == 0:
		print(x, end='')
		break
	elif a[0] * x % 10 == a[1] % 10:
		print(x, end='')
		break


k = [int(x) for x in input().split()]
og = k[0]
counter = 1
while k[0] % 10 != k[1] and k[0] % 10 != 0:
	counter += 1
	k[0] = og * counter
print(counter)


(k, r) = list(map(lambda x: int(x), input().split(' ')))
n = 1
c = k
while (k * n - r) % 10 != 0:
	if k * n % 10 == 0:
		break
	n += 1
print(n)


from sys import stdin
(k, r) = [int(x) for x in stdin.readline().rstrip().split()]
s = 0
s += k
while s % 10 != r and s % 10:
	s += k
print(s // k)


(k, r) = list(map(int, input().split()))
t = k
for i in range(1, 100):
	t = t % 10
	if t == r or t == 0:
		print(i)
		exit(0)
	t += k


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


nums = input().split()
(k, r) = (int(nums[0]), int(nums[1]))
(res, cont) = (1, 0)
aux = True
while aux:
	cont += 1
	res = k * cont
	if res % 10 == 0 or res % 10 == r:
		aux = False
print(cont)


(k, n) = input().split()
k = int(k)
n = int(n)
soma = k
aux = 1
while (soma - n) % 10 != 0:
	if soma % 10 == 0:
		break
	soma += k
	aux += 1
print(aux)


(k, r) = map(int, input().split(' '))
flag = True
i = 1
while flag:
	if k * i % 10 == 0 or (k * i - r) % 10 == 0:
		flag = False
		break
	i += 1
print(i)


num = input().split(' ')
num[0] = int(num[0])
num[1] = int(num[1])
mult = 1
while num[0] * mult % 10 != num[1] and num[0] * mult % 10 != 0:
	mult += 1
print(mult)


z = list(map(int, input().split()))
for i in range(1, 1001):
	if (i * z[0] - z[1]) % 10 == 0 or i * z[0] % 10 == 0:
		print(i)
		break


import sys
fin = sys.stdin
fout = sys.stdout
(k, r) = map(int, fin.readline().split())
ans = 1
while ans < 10:
	if ans * k % 10 == 0 or ans * k == r or ans * k - ans * k // 10 * 10 == r:
		break
	ans += 1
fout.write(str(ans))


(k, r) = list(map(int, input().split()))
cntr = 0
while True:
	cntr += 1
	h = k * cntr
	if h % 10 == 0 or (h - r) % 10 == 0:
		break
print(cntr)


(k, r) = list(map(int, input().split()))
temp = k
shovelnum = 1
while temp % 10 and (temp - r) % 10:
	temp += k
	shovelnum += 1
print(shovelnum)


shovel = [int(i) for i in input().split(' ')]
numberofshovel = 1
flag = True
while flag:
	if numberofshovel * shovel[0] % 10 == shovel[1] or shovel[0] % 10 == 0 or numberofshovel * shovel[0] % 10 == 0:
		print(numberofshovel)
		flag = False
	else:
		numberofshovel += 1


def count_shovel(n, k):
	shovel_count = 1
	while True:
		tail = n * shovel_count % 10
		if tail == 0:
			return shovel_count
		elif tail - k == 0:
			return shovel_count
		shovel_count += 1

def main():
	(n, k) = map(int, input().split())
	print(count_shovel(n, k))
main()


(k, r) = map(int, input().split())
m = 1
while True:
	if r % k == 0:
		break
	if (10 * m + r) % k == 0 or 10 * m % k == 0:
		break
	else:
		m += 1
if r % k == 0:
	print(r // k)
elif (10 * m + r) % k == 0:
	print((10 * m + r) // k)
else:
	print(10 * m // k)


(n, k) = map(int, input().split())
count = 0
t = 1
while True:
	x = n * t
	count += 1
	if x % 10 == 0 or x % 10 == k:
		break
	t += 1
print(t)


def main():
	(k, r) = map(int, input().split())
	i = 1
	while r % 10 != k * i % 10 and k * i % 10 != 0:
		i += 1
	print(i)
main()


(n, r) = map(int, input().split())
for i in range(1, 100000000):
	if n * i % 10 == r or n * i % 10 == 0:
		print(i)
		exit()


(n, r) = input().split()
n = int(n)
r = int(r)
a = n % 10
x = 0
for i in range(1, 11):
	x = x + n
	if n % 10 == r:
		print(i)
		break
	elif x % 10 == r:
		print(i)
		break
	elif n * i % 10 == 0:
		print(i)
		break


inputting = input().split()
k = inputting[0]
r = inputting[1]
number = 0
counter = 0
while True:
	counter += 1
	number = counter * int(k)
	if number % 10 == 0:
		break
	elif (number - int(r)) % 10 == 0:
		break
print(counter)


(n, k) = map(int, input().split())
ans = 1
for i in range(1, 10):
	if (n * i - k) % 10 == 0 or n * i % 10 == 0:
		ans = i
		break
print(str(ans), end='')


(n, k) = [int(i) for i in input().split(' ')]
p = 1
while p >= 1:
	if (n * p - k) % 10 == 0 or n * p % 10 == 0:
		print(p)
		break
	else:
		p += 1


(n, k) = list(map(int, input().split()))
x = n
c = 1
while True:
	if str(n)[-1] == '0' or str(n)[-1] == str(k):
		print(c)
		break
	else:
		n += x
		c += 1


(k, r) = map(int, input().split())
m = 1
temp = k
i = 1
while i > 0:
	if k % 10 == 0 or k % 10 == r:
		break
	k = temp * (i + 1)
	i += 1
	m += 1
print(m)


(k, r) = input(' ').split()
k = int(k)
r = int(r)
i = 1
last_digit = k % 10
while last_digit != r and last_digit != 0:
	i = i + 1
	last_digit = k * i % 10
print(i)


def is_right(charge, r):
	return charge % 10 == 0 or (charge - r) % 10 == 0
(k, r) = tuple(map(int, input().split()))
charge = k
n_shovel = 1
while not is_right(charge, r):
	n_shovel += 1
	charge = k * n_shovel
print(n_shovel)


def trial():
	(k, r) = list(map(int, input().split()))
	for i in range(1, 1000):
		num = k * i
		if num % 10 == r:
			return print(i)
		elif num % 10 == 0:
			return print(i)
trial()


(n, r) = map(int, input().split())
nosh = 1
while 1:
	pr = n * nosh
	if pr % 10 == 0 or (pr - r) % 10 == 0:
		print(nosh)
		break
	nosh += 1


[k, r] = [int(x) for x in input().split()]
i0 = ir = 1
while i0 * k % 10 != 0:
	if i0 >= 10:
		break
	i0 += 1
while ir * k % 10 != r:
	if ir >= 10:
		break
	ir += 1
print(min(i0, ir))


(n, c) = map(int, input().split())
t = n
s = 0
while True:
	s += 1
	if n % 10 == 0 or n % 10 == c:
		break
	n += t
print(s)


(k, r) = map(int, input().split())
c = [k * i % 10 == r or k * i % 10 == 0 for i in range(1, 11)]
print(c.index(True) + 1)


(k, r) = map(int, input().split())
x = 1
while k * x % 10 and (k * x - r) % 10:
	x += 1
print(x)


a = list(map(int, input().split()))
c = 0
b = 0
for i in range(9):
	c += a[0]
	b = i
	if (c - a[1]) % 10 == 0:
		break
	elif c % 10 == 0:
		break
print(b + 1)


(n, m) = map(int, input().split())
i = 0
while True:
	if (i * n % 10 == 0 or i * n % 10 == m) and i != 0:
		break
	else:
		i += 1
print(i)


(c, r) = list(map(int, input().split()))
k = c
answer = 1
while (k - r) % 10 != 0 and k % 10 != 0:
	k = k + c
	answer += 1
print(answer)


(p, r) = map(int, input().split())
res = p
while float((res - r) / 10) - int((res - r) / 10) and float(res / 10) - int(res / 10):
	res += p
print(int(res / p))


import sys
import math

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

def get_list():
	return list(get_ints())

def printspx(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')

def printchk(*args):
	return print(*args, end=' \\ ')
MODPRIME = int(1000000000.0 + 7)
BABYMODPR = 998244353
ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('output.txt', 'w')
(n, k) = get_ints()
(i, val) = (1, n)
while n % 10 != k and n % 10 != 0:
	i += 1
	n += val
print(i)


(a, b) = map(int, input().split())
a = str(a)
t = int(a[len(a) - 1])
h = -1
j = 1
while h < 0 and j < 10:
	m = str(j * t)
	u = int(m[len(m) - 1])
	if u == 0 or u == b:
		h = j
	j += 1
print(h)


def main():
	(price, r) = map(int, input().split())

	def nshovels(price, r, i=1):
		while True:
			if price * i % 10 == r:
				return i
			if price * i % 10 == 0:
				return i
			i += 1
	print(nshovels(price, r))
main()


(k, r) = list(map(int, input().split()))
c = 0
for i in range(1, 100):
	m = i * k
	a = m % 10
	c += 1
	if a == r or a == 0:
		break
print(c)


args = list(map(int, input().split()))
c = 1
while True:
	sum = c * args[0]
	if sum % 10 == 0:
		break
	if (sum - args[1]) % 10 == 0:
		break
	c += 1
print(c)


stats = [int(n) for n in input().split()]
k = stats[0]
r = stats[1]
i1 = 0
for i in range(1, 10):
	if k * i % 10 == 0:
		i1 = i
		break
i2 = 1
while (k * i2 - r) % 10 != 0 and i2 < 11:
	i2 += 1
if i1 != 0:
	print(min(i1, i2))
else:
	print(i2)


(k, r) = map(int, input().split())
i = 1
while True:
	x = str(i * k)
	if x[len(x) - 1] == '0' or x[len(x) - 1] == str(r):
		break
	i = i + 1
print(i)


(a, b) = map(int, input().split())
count = 0
i = 1
while 1:
	x = a * i
	r = x % 10
	if r == b or r == 0:
		count = count + 1
		break
	else:
		count = count + 1
		i = i + 1
print(count)


string = input()
string = string.split(' ')
k = int(string[0])
r = int(string[1])
n = 1
while k * n % 10 != 0 and k * n % 10 != r:
	n += 1
print(n)


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


(k, r) = map(int, input().strip().split(' '))
temp = k
count = 1
while temp % 10 != r and temp % 10 != 0:
	count = count + 1
	temp = k * count
print(count)


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


z = input
(a, b) = list(map(int, z().split()))
c = 0
i = 1
while True:
	c += 1
	p = i * a
	if p % 10 == b or p % 10 == 0:
		print(c)
		break
	i += 1


from sys import stdin
(x, y) = map(int, stdin.readline().split())
for i in range(1, 11):
	if x * i % 10 == y or x * i % 10 == 0:
		print(i)
		break


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


def shovels(k, r):
	cost = k
	found = False
	count = 0
	while not found:
		if cost % 10 == 0 or cost % 10 == r:
			found = True
		count += 1
		cost = (count + 1) * k
	return count
(a, b) = map(int, input().split())
print(shovels(a, b))


from sys import stdin, exit
(k, r) = map(int, stdin.readline().rstrip().split(' '))
cur_k = 1
while True:
	if cur_k * k % 10 == 0 or (cur_k * k - r) % 10 == 0:
		print(cur_k)
		exit()
	cur_k += 1


(price, change) = map(int, input().split())
ans = 1
total = price
while not (total % 10 != 0 and change == total % 10 or total % 10 == 0):
	total += price
	ans += 1
print(ans)


lis = list(map(int, input().split()))
price = lis[0]
r = lis[1]
i = 1
charge = price % 10 % r
while charge != 0 or (price % 10 / r != 1 and price % 10 / r != 0):
	i += 1
	price = lis[0] * i
	charge = price % 10 % r
print(i)


def get_input() -> str:
	raw_input_data = ''
	raw_input_data += input()
	return raw_input_data

def process_input(raw_input_data: str):
	(k, r) = raw_input_data.split(' ')
	return (int(k), int(r))

def solve(raw_input_data):
	(k, r) = process_input(raw_input_data)
	i = 1
	while True:
		q = k * i % 10
		if q == r or q == 0:
			break
		i += 1
	return str(i) + '\n'
while True:
	try:
		input_data = get_input()
		answer = solve(input_data)
		print(answer)
	except:
		break


a = [int(x) for x in input().split()]
i = 1
while True:
	x = i * a[0] % 10
	if x == a[1] or x == 0:
		print(i)
		break
	else:
		i += 1


(a, b) = map(int, input().split())
i = 1
count = 0
while i < 10:
	if i * a % 10 == 0:
		break
	if (i * a - b) % 10 == 0:
		break
	i += 1
print(i)


(price, r) = map(int, input().split())
kol = 1
while True:
	if price * kol % 10 == 0 or price * kol % 10 == r:
		print(kol)
		break
	kol += 1


l = list(map(int, input().strip().split()))
k = l[0]
r = l[1]
for i in range(1, 10 ** 9):
	a = k * i
	if a % 10 == 0:
		print(i)
		break
	elif a % 10 == r:
		print(i)
		break


(k, r) = map(int, input().split())
price = k
shades = 0
while k % 10 != r and k % 10 != 0:
	shades += 1
	k += price
print(shades + 1)


priceAndDenomination = input().split(' ')
priceOfOneShovel = int(priceAndDenomination[0])
denominationOfCoinInPocket = int(priceAndDenomination[1])
noOfShovelsToBuyWithoutChange = 0
while True:
	noOfShovelsToBuyWithoutChange += 1
	if noOfShovelsToBuyWithoutChange * priceOfOneShovel % 10 in [0, denominationOfCoinInPocket]:
		break
print(noOfShovelsToBuyWithoutChange)


import sys
data = sys.stdin.readline().strip().split()
shovelPrice = int(data[0])
count = 1
while True:
	if shovelPrice % 10 == int(data[1]):
		break
	if shovelPrice % 10 == 0:
		break
	shovelPrice += int(data[0])
	count += 1
print(count)


(k, r) = map(int, input().split())
k = k % 10
for n in range(1, 11):
	rem = n * k % 10
	if rem == r or rem == 0:
		print(n)
		break


try:
	(k, r) = input().split()
	k = int(k)
	r = int(r)
	for i in range(1, 100):
		if k * i % 10 == 0:
			print(i)
			break
		elif (k * i - r) % 10 == 0:
			print(i)
			break
except Exception:
	pass


import sys
input = sys.stdin.readline

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

def inlt():
	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) = invr()
multiplier = 1
origx = x
while not x % 10 == 0 and (not x % 10 == y):
	x += origx
	multiplier += 1
print(multiplier)


import sys
import math
import heapq
from collections import defaultdict, deque
input = sys.stdin.readline

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

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

def rl():
	return list(map(int, input().split()))
(k, r) = rm()
cnt = 1
i = 0
j = k
while j % 10 != r and j % 10 != 0:
	cnt += 1
	j += k
print(cnt)


(price_of_shovel, coin) = [int(i) for i in input().split()]
found = False
counter = 0
while not found:
	counter += 1
	if str(price_of_shovel * counter)[-1] in [str(coin), '0']:
		found = True
print(counter)


(k, r) = list(map(int, input().split()))
n = 1
while True:
	d = n * k
	if d % 10 == 0:
		print(n)
		break
	else:
		t = d % 10
		if t == r:
			print(n)
			break
		else:
			n = n + 1


(n, m) = map(int, input().split())
i = 0
while not (i * 10 % n == 0 and i != 0 or (i * 10 + m) % n == 0):
	i += 1
if i * 10 % n == 0 and i != 0:
	print(i * 10 // n)
else:
	print((i * 10 + m) // n)


(a, b) = map(int, input().split())
i = 1
z = a
while a % 10 != b and a % 10 != 0:
	i += 1
	a = z * i
	if i == 10:
		break
print(i)


(a, b) = [int(i) for i in input().split()]
n = 1
while True:
	x = a * n
	if (x - b) % 10 == 0 or x % 10 == 0:
		print(n)
		exit()
	n += 1


vals = {1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], 2: [2, 4, 6, 8, 0], 3: [3, 6, 9, 2, 5, 8, 1, 4, 7, 0], 4: [4, 8, 2, 6, 0], 5: [5, 0], 6: [6, 2, 8, 4, 0], 7: [7, 4, 1, 8, 5, 2, 9, 6, 3, 0], 8: [8, 6, 4, 2, 0], 9: [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]}
(k, r) = list(map(int, input().strip().split(' ')))
if k % 10 != 0:
	if r in vals[k % 10]:
		print(vals[k % 10].index(r) + 1)
	else:
		print(vals[k % 10].index(0) + 1)
else:
	print(1)


(price_one, r) = map(int, input().split())
count_shovel = 0
summary = 0
while summary % 10 != r:
	count_shovel += 1
	summary += price_one
	if summary % 10 == 0:
		break
print(count_shovel)


(k, x) = map(int, input().split())
y = 0
while True:
	if y % k == 0 and y:
		print(y // k)
		break
	if (y + x) % k == 0:
		print((y + x) // k)
		break
	y += 10


(k, r) = map(int, input().split())
ans = 0
sum = 0
while True:
	ans += 1
	sum = ans * k
	if sum % 10 == 0:
		break
	if (sum - r) % 10 == 0:
		break
print(ans)


(k, r) = [int(i) for i in input().split()]
a = k % 10
if a == r:
	print(1)
else:
	i = 1
	j = 1
	for i in range(1, 10000):
		if k * i % 10 == 0:
			break
	for j in range(1000):
		if k * j % 10 == r:
			break
	if i > j:
		print(j)
	else:
		print(i)


(price, coin) = [int(i) for i in input().split()]
for i in range(10):
	if price * (i + 1) % 10 == 0 or price * (i + 1) % 10 == coin:
		print(i + 1)
		exit(0)


N = list(map(int, input().split()))
C = 0
PRICE = N[0]
for _ in range(10):
	if PRICE % 10 == 0 or PRICE % 10 - N[1] == 0:
		print(_ + 1)
		exit()
	PRICE = N[0] * (_ + 2)


(n, k) = map(int, input().split(' '))
count = 1
na = n
while 1:
	if na % 10 == 0 or (na - k) % 10 == 0:
		print(count)
		break
	else:
		count += 1
		na += n


(k, r) = map(int, input().split())
c = k % 10
d = 1
while c != r and c != 0:
	d += 1
	if c * d % 10 == r or c * d % 10 == 0:
		print(d)
		break
else:
	print(d)


(a, b) = map(int, input().split(' '))
if a % 10 - b == 0 or a % 10 == 0:
	print(1)
	exit()
ans = 1
prev = a
while True:
	if a % 10 - b == 0 or a % 10 == 0:
		print(ans)
		exit()
	a = a + prev
	ans = ans + 1


(k, r) = [int(i) for i in input().split()]
total = 0
new = k
i = 1
if str(new)[-1] == str(r) or str(new)[-1] == '0':
	print(1)
else:
	while str(new)[-1] != str(r):
		if str(new)[-1] == '0':
			break
		new = k * i
		total += 1
		i += 1
	print(total)


import sys
import math
input = sys.stdin.readline
(k, r) = map(int, input().split())
coins = 1
while True:
	(cost1, cost2) = (k * coins, k * coins - r)
	if cost1 % 10 == 0 or cost2 % 10 == 0:
		break
	coins += 1
print(coins)


(k, n) = map(int, input().split())
s = k % 10
if s == 0:
	print(1)
else:
	c = 1
	while s / n != 1:
		c = c + 1
		kk = k * c
		s = kk % 10
		if s == 0:
			break
	print(c)


(k, r) = map(int, input().split())
j = k % 10
count = 0
for i in range(1, 10):
	if r == i * j % 10 or i * k % 10 == 0:
		print(i)
		count += 1
		break
	elif k % 10 == 0:
		print(1)
		count += 1
		break
	elif r % k == 0:
		print(int(r / k))
		count += 1
		break


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


from sys import stdin
(k, r) = map(int, stdin.readline().split())
k = k % 10
for i in range(1, 10):
	n = k * i
	if n % 10 == 0 or n % 10 == r:
		print(i)
		break
else:
	print(10)


def solution(k, r):
	i = 1
	while True:
		if i * k % 10 == 0:
			return i
		elif (i * k - r) % 10 == 0:
			return i
		i += 1
(k, r) = map(int, input().split())
print(solution(k, r))


a = list(map(int, input().split(' ')))
p = a[0]
c = a[1]
(n, total) = (1, p)
while True:
	if total % 10 == 0 or (total - c) % 10 == 0:
		break
	else:
		total += p
		n += 1
print(n)


(k, r) = map(int, input().split())
buying = True
i = 1
while buying:
	if k * i % 10 == r:
		break
	elif k * i % 10 == 0:
		break
	else:
		i += 1
print(i)


(n, m) = map(int, input().split())
i = 1
while i:
	x = n * i
	if x % 10 == 0 or x % 10 == m:
		print(i)
		break
	i += 1


(k, r) = map(int, input().split())
i = 1
last = int(str(k)[-1])
while r != last and 0 != last:
	k1 = k * i
	last = int(str(k1)[-1])
	i += 1
if i == 1:
	print(1)
else:
	print(i - 1)


(n, k) = map(int, input().split())
i = 1
while True:
	if n * i % 10 == k or n * i % 10 == 0:
		print(i)
		exit(0)
	i += 1


(A, B) = [int(d) for d in input().split(' ')]
c = 1
d = c * A
while d % 10 != 0 and d % 10 - B != 0:
	c += 1
	d = c * A
print(c)


(k, r) = list(map(int, input().split()))
last = k % 10
count = None
for d in range(1, 10):
	if last * d % 10 == r:
		count = d
		break
if not count:
	for d in range(1, 10):
		if k * d % 10 == 0:
			count = d
			break
print(count)


(k, r) = map(int, input().split())
cnt = 1
while True:
	if not k * cnt % 10:
		break
	if not (k * cnt - r) % 10:
		break
	cnt += 1
print(cnt)


i = 1
line = input()
pieces = line.split()
k = int(pieces[0])
r = int(pieces[1])
while i < 11:
	n = k * i
	s = str(n)
	b = int(s[-1])
	if b == r:
		print(i)
		break
	if b == 0:
		print(i)
		break
	i = i + 1


(k, r) = [int(k) for k in input().split()]
stri = []
for i in range(1, 11):
	ans = k * i
	ans = str(ans)
	interm = int(ans[len(ans) - 1])
	if interm >= r:
		stri = stri + [interm - r]
	elif interm == 0:
		stri = stri + [0]
	else:
		stri = stri + [11]
for i in range(0, 10):
	stri[i] = abs(stri[i])
print(stri.index(min(stri)) + 1)


from math import *
import sys, bisect, copyreg, copy, statistics, os

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

def IIX():
	return (int(x) for x in sys.stdin.readline().split())

def II():
	return int(inp())

def LI():
	return list(map(int, inp().split()))

def LS():
	return list(map(str, inp().split()))

def L(x):
	return list(x)

def out(var):
	return sys.stdout.write(str(var))
(k, r) = LI()
for i in range(1, 10):
	if k * i % 10 == r:
		out(i)
		break
	elif k * i % 10 == 0:
		out(i)
		break


kandr = input().split()
k = int(kandr[0])
r = int(kandr[1])
init = k
flag = 1
while True:
	if (k - r) % 10 == 0 or k % 10 == 0:
		break
	flag += 1
	k += init
print(flag)


[k, r] = list(map(int, input().split()))
m = 1
while True:
	if k * m % 10 == r or k * m % 10 == 0:
		print(m)
		exit(0)
	m += 1


(k, r) = map(int, input().split())
c = 0
price = k
while c <= 10:
	if (price - r) % 10 == 0 or price % 10 == 0:
		break
	else:
		price += k
		c += 1
print(c + 1)


(cost, money) = input().split()
cost = int(cost)
money = int(money)

def check(count, cost, money):
	return (count * cost - money) % 10 == 0 or count * cost % 10 == 0
i = 1
while not check(i, cost, money):
	i += 1
print(i)


x = input()
x = x.split()
k = int(x[0])
r = int(x[1])
n = 1
while n * k % 10 != 0:
	if (n * k - r) % 10 == 0:
		break
	n += 1
print(n)


nums = list(map(int, input().split(' ')))
price = initial_price = nums[0]
shovels = 1
while True:
	difference = int(price % 10)
	if difference == nums[1] or difference == 0:
		print(shovels)
		break
	shovels += 1
	price += initial_price


(k, r) = map(int, input().split())
sumValue = k
answer = 1
while k % 10 - r != 0:
	if k % 10 == 0:
		break
	k += sumValue
	answer += 1
print(answer)


(k, r) = map(int, input().split())
orig = k
c = 1
l_digit = int(str(k)[-1])
while l_digit not in [r, 0]:
	k += orig
	c += 1
	l_digit = int(str(k)[-1])
print(c)


from itertools import product
(k, r) = map(int, input().split())
cond = False
for i in range(1, 10):
	x = [a for a in range(int(i * k / 10) + 1)]
	y = [0, 1]
	comb = list(product(x, y))
	for j in comb:
		if 10 * j[0] + r * j[1] == i * k:
			print(i)
			cond = True
			break
	if cond:
		break
else:
	print(10)


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


(k, r) = map(int, input().split())
i = 1
while True:
	t = (i * k - r) % 10 == 0
	u = i * k % 10 == 0
	i += 1
	if t or u:
		break
print(i - 1)


(cost, coin) = [int(x) for x in input().split()]

def pidorskie_zadachi(cost, coin):
	if cost % 10 == coin or cost % 10 == 0:
		return True
	return False
for i in range(1, 11):
	if pidorskie_zadachi(cost * i, coin):
		print(i)
		break


(m, d) = map(int, input().split())
(x, M) = (1, 1)
while True:
	M = m * x
	if M % 10 == 0:
		print(x)
		c = 1
		break
	elif (M - d) % 10 == 0:
		print(x)
		c = 1
		break
	x += 1


from math import ceil, sqrt, gcd, log, floor
from collections import deque

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

def si():
	return input()

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

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

def main():
	(n, m) = mi()
	for i in range(1, 1000):
		x = n * i
		if x % 10 == 0:
			print(i)
			break
		if x % 10 == m:
			print(i)
			break
main()


money = input().split(' ')
shovels = 10
for i in range(1, 10):
	if int(money[0]) * i % 10 == 0 or (int(money[0]) * i - int(money[1])) % 10 == 0:
		shovels = i
		break
print(shovels)


a = input().split(' ')
harga = int(a[0])
bantuan = int(a[1])
for x in range(1, 11):
	if x * harga % 10 == 0:
		print(x)
		break
	elif (x * harga - bantuan) % 10 == 0:
		print(x)
		break


(n, m) = [int(j) for j in input().split()]
N = n
count = 1
while n % 10 != m and n % 10 != 0:
	count += 1
	n += N
print(count)


(K, R) = tuple(map(int, input().split(' ')))
for i in range(1, 10):
	cost = i * K
	if cost % 10 in [R, 0]:
		print(i)
		break


import sys
import itertools
fin = sys.stdin
(k, r) = fin.readline().split()
k = int(k)
r = int(r)
total = 0
n = 1
while True:
	total = n * k
	if total % 10 == 0 or total % 10 == r:
		break
	n += 1
print(n)


(k, r) = map(int, input().split())
rem = {0, r}
for i in range(1, 11):
	mod = i * k % 10
	if mod in rem:
		break
print(i)


(k, r) = map(int, input().split())
i = 0
sum = 0
flag = 1
while flag == 1:
	sum += k
	if sum % 10 == r or sum % 10 == 0:
		print(i + 1)
		flag = 0
	else:
		i += 1


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


(k, r) = input().split(' ')
(k, r) = (int(k), int(r))
minimum_found = False
num_shovel = 1
while True:
	if k * num_shovel % 10 == r or k * num_shovel % 10 == 0:
		break
	else:
		num_shovel += 1
print(num_shovel)


(a, b) = map(int, input().split())
c = 0
sum = a
while True:
	c += 1
	if sum % 10 == 0:
		break
	elif (sum - b) % 10 == 0:
		break
	else:
		sum += a
print(c)


ipt = [int(x) for x in input().split()]
k = ipt[0]
r = ipt[1]
for i in range(1, 10):
	tmp = str(k * i)
	if tmp[-1] == str(r) or tmp[-1] == '0':
		print(i)
		break
else:
	print(10)


import math
(s, k) = map(int, input().split())
c = 0
d = 10
i = 1
while True:
	if s * i % 10 == 0 or s * i % 10 == k:
		break
	c += 1
	i += 1
print(c + 1)


(k, r) = [int(x) for x in input().split()]
last = k % 10
p = last
ans = 1
while p != 0 and p != r:
	ans += 1
	p = last * ans % 10
print(ans)


(n, m) = map(int, input().split())
q = n % 10
for i in range(1, 100000):
	b = q * i % 10
	if b == 0 or b == m:
		print(i)
		exit()


def min_shovel(k, r):
	i = 1
	k_org = k
	while 1:
		k = i * k_org
		i += 1
		if k % 10 == 0 or (k - r) % 10 == 0:
			return i - 1
(k, r) = list(map(int, input().split()))
n = min_shovel(k, r)
print(n)


(A, B) = map(int, input().split())
(P, Q) = (1, A)
while A % 10 != B and A % 10 != 0:
	P += 1
	A += Q
print(P)


(k, r) = map(int, input().split(' '))
if k % 10 == 0:
	print(1)
else:
	s = 0
	c = 0
	while s % 10 != r:
		if s % 10 == 0:
			if s > 0:
				print(c)
				exit(0)
		s += k
		c += 1
	print(c)


from collections import deque
from collections import Counter
from itertools import permutations
import heapq

def counterExample():
	arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]
	counter = Counter(arr)
	top_three = counter.most_common(3)
	print(top_three)
q = deque()

def main():
	(k, r) = tuple([int(i) for i in input().split()])
	f = 1
	while f * k % 10 != 0 and (f * k - r) % 10 != 0:
		f += 1
	print(f)
main()


(k, r) = [int(i) for i in input().split(' ')]
i = 0
while 1:
	i += 1
	a = k * i % 10
	if a == 0 or a == r:
		print(i)
		break


def main():
	(k, r) = input().split()
	i = 1
	t = int(k[-1])
	while i <= 10:
		if int(str(t)[-1]) == int(r):
			print(i)
			break
		elif int(str(t)[-1]) == 0:
			print(i)
			break
		else:
			t += int(k[-1])
		i += 1
main()


m = list(map(int, input().split(' ')))
p = m[0]
r = m[1]
if p % 10 == 0:
	print(1)
elif p % 10 == r:
	print('1')
elif p % 10 == 5:
	print('2')
else:
	c = 1
	while 1:
		x = p * c
		if x % 10 == r or x % 10 == 0:
			print(c)
			break
		c += 1


(k, r) = map(int, input().split())
ans = 1
k %= 10
kk = k % 10
while k % 10 not in [r, 0]:
	k = (k + kk) % 10
	ans += 1
print(ans)


n = input().split()
s1 = n[0]
x = int(s1[len(s1) - 1])
y = 1
while x != int(n[1]):
	if x == 0:
		break
	y += 1
	z = y * int(s1)
	x = z % 10
print(y)


(k, n) = map(str, input().split())
k2 = int(k)
n2 = int(n)
i = 2
if k[-1] == n:
	print(1)
elif k[-1] == '0':
	print(1)
else:
	while True:
		temp = k2 * i
		temp = str(temp)
		if temp[-1] == n or temp[-1] == '0':
			print(i)
			break
		else:
			i += 1


(k, r) = map(int, input().split())
c = 1
while True:
	t = c * k
	if t % 10 == 0:
		print(c)
		exit()
	t -= r
	if t % 10 == 0:
		print(c)
		exit()
	c += 1


(k, r) = list(map(int, input().split()))
cont = 1
while k * cont % 10 != r and k * cont % 10 != 0:
	cont += 1
print(cont)


l = list(map(int, input().rstrip().split()))
x = l[0]
y = l[1]
p = 1
for i in range(1, 10):
	p = x * i
	if p % 10 == y or p % 10 == 0:
		z = i
		break
print(z)


(cost_spade, r) = map(int, input().split())
count = 0
while True:
	if count == 10:
		break
	count += 1
	all_cost = cost_spade * count
	if all_cost % 10 == 0:
		print(count)
		break
	if all_cost % 10 != r:
		continue
	else:
		print(count)
		break


__author__ = 'linh'

def main():
	s = input()
	s = list(map(int, s.split()))
	k = s[0]
	r = s[1]
	for i in range(1, 11):
		if k * i % 10 == 0 or (k * i - r) % 10 == 0:
			print(i)
			return
main()


(k, r) = input().split()
k = int(k)
r = int(r)
lis = []
c = 1
for i in range(1, 1001):
	x = k * i
	lis.append(x)
l = len(lis)
for j in range(l):
	if lis[j] % 10 == 0:
		print(c)
		break
	if lis[j] % 10 == r:
		print(c)
		break
	c = c + 1


(k, r) = map(int, input().split())
count = 1
k1 = k
j = 2
while 1:
	if k1 % 10 == r or k1 % 10 == 0:
		break
	count += 1
	k1 = k * j
	j += 1
print(count)


(k, r) = map(int, input().split())
x = k
c = 1
while x % 10 != 0 and x % 10 != r:
	x = x + k
	c += 1
out = c
print(out)


x = list(map(int, input().split(' ')))
a = 1
while True:
	if x[0] * a % 10 == 0:
		print(a)
		break
	elif x[0] * a % 10 - x[1] == 0:
		print(a)
		break
	else:
		a += 1


(k, r) = map(int, input().split())
tot = 0
c = 1
while True:
	tot += k
	if tot % 10 == 0:
		break
	elif (tot - r) % 10 == 0:
		break
	c += 1
print(c)


(priceShovel, denom) = list(map(int, input().split(' ')))
numShovels = 1
newPrice = priceShovel
while newPrice % 10 != 0 and newPrice % 10 != denom:
	newPrice = priceShovel * (numShovels + 1)
	numShovels += 1
print(numShovels)


import math
(n, k) = map(int, input().split())
i = 1
m = 1000
while i <= m:
	if n * i % 10 == 0:
		print(i)
		break
	if (n * i - k) % 10 == 0:
		print(i)
		break
	i = i + 1


import math
import os
import random
import re
import sys
a = input().split()
n = int(a[0])
m = int(a[1])
i = 1
d = 1
while d != 0:
	b = n * i
	e = b % 10
	c = (b - m) % 10
	d = min(e, c)
	i = i + 1
print(i - 1)


(k, r) = [int(x) for x in input().split()]
s = 1
t = k
i = 1
while i > 0:
	if k % 10 == 0 or k % 10 == r:
		break
	k = t * (i + 1)
	i += 1
	s += 1
print(s)


(price, dedomination) = map(int, input().split(' '))
mod = price % 10
number = 0
for i in range(1, 10):
	a = mod * i % 10
	if a == 0 or a == dedomination:
		number = i
		break
print(number)


(x, r) = map(int, input().split())
s = x
while (s - r) % 10 != 0 and s % 10 != 0:
	s += x
print(s // x)


(price, r) = list(map(int, input().split()))
n = 1
sum = price
while True:
	if sum % 10 == 0 or sum % 10 == r:
		break
	else:
		sum = sum + price
		n += 1
print(n)


def solve(k, r):
	count = 0
	cost = k
	while cost % 10 != 0 and cost - r != 0 and (cost % 10 - r != 0):
		count += 1
		cost += k
	print(count + 1)
(k, r) = map(int, input().split())
solve(k, r)


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


(k, r) = map(int, input().split())
n1 = 0
n2 = 0
money = 0
i = 0
for i in range(0, 10000):
	money = 10 * i + r
	if money % k == 0:
		n1 = money / k
	money = 10 * i
	if money % k == 0:
		n2 = money / k
	if n1 != 0 and n2 == 0:
		print(int(n1))
		break
	elif n2 != 0 and n1 == 0:
		print(int(n2))
		break
	elif n1 == 0 and n2 == 0:
		continue
		if n1 > n2:
			print(int(n2))
			break
		elif n2 > n1:
			print(int(n1))
			break


values = input('').split(' ')
values = [int(i) for i in values]
count = 0
shovels = 0
for i in range(11):
	if (values[0] * (i + 1) - values[1]) % 10 == 0 or values[0] * (i + 1) % 10 == 0:
		shovels = i + 1
		break
print(shovels)


from copy import deepcopy
(a, b) = list(map(int, input().split()))
count = 1
while True:
	if a * count % 10 == 0 or a * count % 10 == b:
		break
	count += 1
print(count)


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


userinput = input()
mylist = userinput.split(' ')
k = int(mylist[0])
r = int(mylist[1])
perfect_price = None
i = 0
while True:
	i += 1
	perfect_price = k * i
	if perfect_price % 10 == 0 or perfect_price % 10 == r:
		break
print(i)


string = input()
split = string.split(' ')
k = int(split[0])
r = int(split[1])
ending = int(split[0][len(split[0]) - 1])
multiplier = -1
for i in range(1, 10):
	times = str(ending * i)
	end = times[len(times) - 1]
	if int(end) == r:
		multiplier = i
		break
ten = -1
for i in range(1, 10):
	times = str(ending * i)
	end = times[len(times) - 1]
	if int(end) == 0:
		ten = i
		break
if multiplier != -1:
	if ten != -1:
		if multiplier < ten:
			print(multiplier)
		elif multiplier > ten:
			print(ten)
		else:
			print(multiplier)
	else:
		print(multiplier)
elif ten != -1:
	print(ten)
else:
	print(10)


import sys
from math import gcd
(k, r) = map(int, sys.stdin.read().strip().split())
mx = 10 // gcd(k, 10)
for i in range(1, mx + 1):
	if k * i % 10 == r:
		break
print(i)


(k, r) = map(int, input().split(' '))
k0 = k
var = True
while var:
	if (k - r) % 10 == 0:
		print(k // k0)
		var = False
	elif k % 10 == 0:
		print(k // k0)
		var = False
	else:
		k = k + k0


(k, r) = map(int, input().split())
it = 1
while it <= 10:
	v = k * it
	if (v - r) % 10 == 0 or v % 10 == 0:
		break
	it += 1
print(min(it, 10))


(k, r) = map(int, input().split())
N = 1
ost = k % 10
if k % 10 == 0:
	print('1')
elif ost % 10 == r:
	print('1')
elif ost == 1:
	print(int(r))
elif ost == 5:
	print('2')
elif k % 2 == 0 and r % 2 != 0:
	print('5')
else:
	while ost * N % 10 != r:
		N += 1
		continue
	else:
		print(N)


(p, coin) = map(int, input().split())
buy = 0
for i in range(1, 11):
	if (p * i - coin) % 10 == 0:
		buy = i
		break
	elif p * i % 10 == 0:
		buy = i
		break
print(buy)


s = input()
(price, coins) = s.split()
price = int(price)
coins = int(coins)
c = 1
while True:
	if price * c % 10 == coins or price * c % 10 == 0:
		print(c)
		break
	c += 1


(k, r) = map(int, input().strip().split())
c = 1
t = k
while 1:
	if t % 10 == 0 or t % 10 == r:
		print(c)
		break
	else:
		t += k
		c += 1


(k, r) = map(int, input().split())
if k % 10 == 0:
	print(1)
	exit()
elif k % 10 == r:
	print(1)
	exit()
s = 0
for i in range(15):
	s += k
	if s % 10 == r or s % 10 == 0:
		print(i + 1)
		break


(n, m) = map(int, input().split())
k = n
for i in range(2, 1000):
	if n % 10 != m and n % 10 != 0:
		n = k * i
	else:
		print(i - 1)
		break


(k, r) = [int(x) for x in input().split()]
nb_shovels = 1
price = k
while price % 10 != 0 and price % 10 != r:
	price += k
	nb_shovels += 1
print(nb_shovels)


(price, change) = map(int, input().split())
initialAmount = price
while price % 10 != 0 and price % 10 != change:
	price += initialAmount
print(price // initialAmount)


(k, r) = [int(_) for _ in input().split()]
ans = 1
while True:
	if ans * k % 10 == 0 or ans * k % 10 == r:
		break
	ans += 1
print(ans)


(k, r) = map(int, input().split())
digit = k % 10
for x in range(1, 10):
	if digit * x % 10 == r or digit * x % 10 == 0:
		print(x)
		break
else:
	print(10)


(k, r) = map(int, input().strip().split())
c = 1
p = k
while True:
	if p % 10 == r or p % 10 == 0:
		break
	c += 1
	p = k * c
print(c)


(k, r) = list(map(int, input().split()))
a = k % 10
c = 0
for i in range(1, 10):
	if i * a % 10 == r:
		c = i
		break
if c == 0:
	for i in range(1, 11):
		if i * k % 10 == 0:
			print(i)
			break
else:
	print(c)


import math
str = input().split()
k = int(str[0])
r = int(str[1])
i = 1
while not (i * k % 10 == 0 or i * k % 10 - r == 0):
	i += 1
print(i)


def kd(k, c):
	t = k
	s = 1
	while t % 10 != 0 and t % 10 != c:
		t += k
		s += 1
	print(s)
(k, c) = list(map(int, input().split()))
kd(k, c)


(a, b) = map(int, input().split())
c = 1
z = True
while z:
	if c * a % 10 == 0 or (a * c - b) % 10 == 0:
		print(c)
		z = False
	else:
		c += 1
		z = True


(k, r) = list(map(int, input().strip().split(' ')))
d = k % 10
t = d
count = 1
for i in range(1, 11):
	if d == 0 or d == r:
		print(count)
		break
	d = d + t
	count += 1
	d = d % 10


(k, r) = map(int, input().split())
(r, s, i) = (str(r), str(k), 1)
while s[-1] != r:
	if s[-1] == '0':
		break
	i += 1
	s = str(k * i)
print(i)


(prix, oseille) = map(int, input().split())
for i in range(1, 10):
	if prix * i % 10 == oseille or prix * i % 10 == 0:
		print(i)
		exit(0)


(price, moneta) = map(int, input().split())
i = 1
cost = 0
while True:
	cost = cost + price
	if cost % 10 == moneta:
		print(i)
		break
	if cost % 10 == 0:
		print(i)
		break
	i += 1


import sys
numbers = [int(i) for i in sys.stdin.readline().split()]
k = numbers[0]
r = numbers[1]
i = 1
while i <= 10:
	if k % 10 == 0:
		print(1)
		sys.exit()
	if k * i % 10 == 0:
		print(i)
		sys.exit()
	if i * k == i * k - i * k % 10 + r:
		print(i)
		sys.exit()
	i += 1


(s, c) = [int(x) for x in input().split()]
i = 1
while True:
	if i * s % 10 == 0 or (i * s - c) % 10 == 0:
		break
	i += 1
print(i)


kr = input().strip().split(' ')
k = int(kr[0])
r = int(kr[1])
x = 1
while True:
	if x * k % 10 == r or x * k % 10 == 0:
		break
	else:
		x += 1
print(x)


(k, r) = [int(x) for x in input().split()]
for i in range(1, 11):
	if int(str(k * i)[-1]) == r or int(str(k * i)[-1]) == 0:
		print(i)
		break


(k, r) = map(int, input().split())
z = k - r
if z % 10 == 0 or k % 10 == 0:
	print(1)
else:
	for i in range(2, 11):
		z = k * i
		if (z - r) % 10 == 0 or z % 10 == 0:
			print(i)
			break


(kk, n) = list(map(int, input().strip().split(' ')))
cnt = 0
i = 1
k = kk
while True:
	if k % 10 == 0 or k % 10 == n:
		print(i)
		break
	else:
		i = i + 1
		k = k + kk


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


(k, r) = map(int, input().split())
print(min((n for n in range(1, 10) if n * k % 10 == r or n * k % 10 == 0)))


num = input().split()
k = int(num[0])
r = int(num[1])
produto = 1
while True:
	numero = k * produto
	if numero % 10 == r or numero % 10 == 0:
		break
	produto += 1
print(produto)


(k, r) = map(int, input().split())
import sys
for i in range(1, 11):
	a = k * i % 10
	if a == 0 or a == r:
		print(i)
		sys.exit()


a = list(map(int, input().split()))
x = a[0]
y = a[1]
for i in range(1, 10):
	k = a[0] * i
	rem = k % 10
	if rem == 0 or rem == y:
		print(i)
		break


def solution():
	(k, r) = map(int, input().split())
	for i in range(1, 10):
		digit = k * i % 10
		if not digit or digit == r:
			print(i)
			break
	else:
		print(10)
solution()


(k, r) = map(int, input().split())
l = []
for x in range(1, 11):
	if x * k % 10 == 0 or x * k % 10 == r:
		l.append(x)
print(min(l))


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


(k, r) = map(int, input().split())
k = int(str(k)[-1])
idx = ([False] + [(k * i - r) % 10 == 0 or k * i % 10 == 0 for i in range(1, 10)] + [True]).index(True)
print(idx)


(k, r) = [int(x) for x in input().split()]
number = 0
price = 0
shovel = 0
while shovel < k:
	shovel += 10
price = shovel - 10
condition = True
while condition:
	if not (price + r) % k:
		price += r
		break
	else:
		price += 10
	if price != 0:
		if not price % k:
			condition = False
print(int(price / k))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, 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 [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 pf(s):
	return print(s, flush=True)

def main():
	(a, b) = LI()
	for i in range(1, 11):
		if i * a % 10 in [0, b]:
			return i
	return -1
print(main())


(k, r) = map(int, input().split())
t = True
i = 0
while t:
	i = i + 1
	cost = k * i
	if cost % 10 == 0 or cost % 10 == r:
		t = False
print(i)


(i, j) = input().split()
i = int(i[-1])
j = int(j)
ori = i
counter = 1
while (i - j) % 10 != 0 and i % 10 != 0:
	counter += 1
	i += ori
print(counter)


(k, r) = map(int, input().split())
change = k % 10
count = 1
while change != r:
	if change == 0:
		break
	change += k % 10
	if change >= 10:
		change -= 10
	count += 1
print(count)


(k, r) = [int(i) for i in input().split()]
i = 1
y = 0
while True:
	y += k
	x = y % 10
	if x == r or x == 0:
		break
	i += 1
print(i)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

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

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def def_value():
	return 0
(n, k) = invr()
for i in range(1, 11):
	temp = n * i
	if temp % 10 == k or temp % 10 == 0:
		print(i)
		break


import sys
import math as mt
t = 1
for __ in range(t):
	(k, r) = map(int, input().split())
	mini = k * 10
	for i in range(1, 11):
		if (k * i - r) % 10 == 0 or k * i % 10 == 0:
			mini = min(i, mini)
			break
	print(mini)


(n, m) = map(int, input().split())
c = 1
s = n
while 1:
	if s % 10 == 0 or (s - m) % 10 == 0:
		break
	else:
		c += 1
		s = c * n
print(c)


(k, r) = map(int, input().split())
minim = 1
while 0 != minim * k % 10 != r:
	minim += 1
print(minim)


from sys import stdin, stdout

def ri():
	return map(int, stdin.readline().split())
(k, r) = ri()
a = 10 ** 9
b = 10 ** 9
for i in range(10 ** 5):
	if (10 * i + r) % k == 0:
		a = (10 * i + r) // k
		break
for i in range(1, 10 ** 5):
	if 10 * i % k == 0:
		b = 10 * i // k
		break
print(min(a, b))


(cost, r) = map(int, input().split())
count = 1
while count * cost % 10 != 0:
	if (count * cost - r) % 10 == 0:
		break
	count += 1
print(count)


(k, r) = map(int, input().split())
for i in range(1, 1000001):
	xx = k * i
	if xx % 10 == r or xx % 10 == 0:
		print(i)
		exit()


(a, b) = map(int, input().split())
k = 1
d = a
g = a
if a % 10 == 0:
	print(k)
elif a % 10 == b:
	print(k)
else:
	for i in range(0, 9):
		g = g + a
		if g % 10 == 0:
			print(g // d)
			break
		elif g % 10 == b:
			print(g // a)
			break


(k, r) = map(int, input().split())
x = 1
s = 0
if (s - r) % 10 == 0:
	print(1)
else:
	while 0 != x * k % 10 != r:
		x += 1
	print(x)


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


(a, b) = list(map(int, input().split()))
p = 1
while True:
	r = a * p
	if r % 10 == 0 or r % 10 == b:
		print(p)
		break
	p += 1


(k, r) = map(int, input().split())
flag = True
count = 1
while flag:
	if k * count % 10 == 0 or (k * count - r) % 10 == 0:
		flag = False
	else:
		count += 1
print(count)


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


import sys
from math import ceil, log
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

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

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('Yes')

def NO():
	print('No')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k) = RI()
temp = n % 10
if temp == 0:
	print(1)
	exit()
i = 0
for i in range(1, 11):
	if temp * i % 10 == k or temp * i % 10 == 0:
		break
print(i)


(a, b) = map(int, input().split())
c = a
while True:
	if a == a // 10 * 10 + b:
		break
	if a % 10 == 0:
		break
	a += c
print(a // c)


(k, r) = map(int, input().split())
x = 1
y = str(k)
while True:
	z = list(y)
	if z[-1] == str(r) or z[-1] == '0':
		print(x)
		break
	else:
		x += 1
		y = str(x * k)


(n, k) = input().split()
n = int(n)
k = int(k)
for i in range(1, 1000):
	if i * n % 10 == k or i * n % 10 == 0:
		print(i)
		exit()


(k, r) = map(int, input().split())
list1 = []
for i in range(1, 10):
	list1.append(str(k * i))
for i in range(len(list1)):
	if list1[i][-1] == '0' or list1[i][-1] == str(r):
		print(i + 1)
		break


TN = 1

def solution():
	(k, r) = map(int, input().split())
	ans = 10
	for i in range(1, 10):
		if k * i % 10 == 0:
			ans = i
			break
		elif k * i % 10 == r:
			ans = i
			break
	print(ans)
while TN != 0:
	solution()
	TN -= 1


def main():
	(k, r) = [int(x) for x in input().split()]
	print(solve(k, r))

def solve(k, r):
	quantidade_pa = 1
	aux = k
	while True:
		unidade = aux % 10
		if unidade == 0 or unidade == r:
			return quantidade_pa
		quantidade_pa += 1
		aux += k
main()


import sys
(k, r) = map(int, sys.stdin.readline().split())
(ans, printed) = (1, False)
while ans < 10:
	d = ans * k % 10
	if d == r or d == 0:
		print(ans)
		printed = True
		break
	ans += 1
if printed is False:
	print(10)


(k, r) = map(int, input().split())
line = []
for i in range(1, 10):
	line.append([i, i * k])
for j in range(9):
	if line[j][1] % 10 == r or line[j][1] % 10 == 0:
		print(line[j][0])
		break


def solve(k, r):
	possible_remainders = {0, r}
	i = 1
	while True:
		mod = i * k % 10
		if mod in possible_remainders:
			return i
		else:
			i += 1
(k, r) = list((int(x) for x in input().split()))
print(solve(k, r))


(harga, koin) = map(int, input().split())
harga = harga % 10
cek = harga
hasil = 1
while True:
	if harga == 0 or harga == koin:
		break
	hasil += 1
	harga = (harga + cek) % 10
print(hasil)


import sys

def main():
	prices = [0] * 10
	(k, r) = map(int, input().split())
	for i in range(10):
		prices[i] = k * (i + 1)
	for i in range(20):
		if prices[i] % 10 == 0 or prices[i] % 10 == r:
			print(i + 1)
			return
sys.exit(main())


(k, r) = map(int, input().split(' '))
res = 1
while 1:
	if k < 10 and k == r:
		print(1)
		break
	if k % 10 == 0:
		print(1)
		break
	if (res * k - r) % 10 == 0:
		print(res)
		break
	elif res * k % 10 == 0:
		print(res)
		break
	res += 1


(k, r) = map(int, input().split())
count = 0
for i in range(1, 11):
	l = k * i
	if l % 10 == 0:
		count = i
		break
	elif int(str(l)[-1]) == r:
		count = i
		break
print(count)


(k, r) = map(int, input().split())
ans = 1
while True:
	a = k * ans % 10
	if a == 0 or a == r:
		print(ans)
		exit()
	ans += 1


import math
import sys
import heapq
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def factorial(n):
	if n < 0:
		return 0
	elif n == 0 or n == 1:
		return 1
	else:
		fact = 1
		while n > 1:
			fact *= n
			n -= 1
		return fact

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def solve():
	i = 0
	(k, r) = map(int, input().split())
	b = True
	while b:
		i += 1
		h = k * i
		if h % 10 == 0 or h % 10 == r:
			b = False
	return i
print(solve())


(k, r) = [int(x) for x in input().split()]
if k % 10 == 0 or str(k).endswith(str(r)):
	print(1)
elif k % 5 == 0:
	print(2)
else:
	m = 2
	while True:
		ks = k * m
		if ks % 10 == 0 or str(ks).endswith(str(r)):
			print(m)
			break
		m += 1


def answer():
	a = input().split()
	c = int(a[0])
	r = int(a[1])
	i = 1
	d = c
	while True:
		if d % 10 == r or d % 10 == 0:
			return max(i - 1, 1)
		d = c * i
		i += 1
print(answer())


(k, r) = map(int, input().split())
p = str(k)
p1 = int(p[-1])
total = 0
find = 1
i = 1
if p1 == 0:
	print(1)
elif p1 == r:
	print(1)
elif p1 == 5:
	print(2)
else:
	while find == 1:
		if p1 * i % 10 == 0 or (p1 * i - r) % 10 == 0:
			print(i)
			find = 0
		else:
			i += 1


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


(k, r) = map(int, input().split())
l = k
value = 0
i = 0
while (l - r) % 10 != 0:
	i += 1
	l = k * i
	value += 1
	if l % 10 == 0:
		break
print(value if value > 0 else 1)


(k, r) = [int(v) for v in input().split(' ')]
num_shovels = 1
while True:
	if k * num_shovels % 10 == r or k * num_shovels % 10 == 0:
		print(num_shovels)
		break
	num_shovels += 1


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


(price, r) = map(int, input().split())
i = 1
temp = price
while 1:
	if (temp - r) % 10 == 0 or temp % 10 == 0:
		print(i)
		break
	else:
		temp += price
		i += 1


import copy
from itertools import count

def main():
	(n, r) = input().split()
	number_of_shovel = 0
	n = int(n)
	r = int(r)
	for i in count(1):
		curr_money = n * i
		if (curr_money - r) % 10 == 0 or curr_money % 10 == 0:
			number_of_shovel = i
			break
	print(number_of_shovel)
main()


def NewYear():
	(k, r) = list(map(int, input().split()))
	cost = k
	shovels = 1
	while k % 10 != r and k % 10 != 0:
		shovels += 1
		k += cost % 10
	print(shovels)
NewYear()


(k, i) = map(int, input().split())
p = 0
l = 1
while p == 0:
	if k * l % 10 == 0 or k * l % 10 - i == 0:
		p = 1
	l += 1
print(l - 1)


(p, r) = [int(x) for x in input().split()]
n = 1
while p * n % 10 not in [0, r]:
	n += 1
print(n)


(n, m) = map(int, input().split())
n %= 10
curr = n
res = 1
while curr != m and curr != 0:
	curr += n
	curr %= 10
	res += 1
print(res)


(k, r) = map(int, input().split())
e1 = k
count = 1
while k % 10 != 0 and (k - r) % 10 != 0:
	count += 1
	k += e1
print(max(1, count))


import math
(p, r) = map(int, input().split())
k = 1
count = 1
while 1:
	n = (p * k - r) / 10
	nwr = p * k / 10
	if n == int(n) or nwr == int(nwr):
		print(count)
		break
	k += 1
	count += 1


n = 1
(k, r) = input().split()
k = int(k)
while 1:
	if n * k % 10 == 0:
		print(n)
		exit()
	elif str(n * k)[-1] == r:
		print(n)
		exit()
	n += 1


(k, r) = map(int, input().split())
count = 1
c = k
while (k - r) % 10 != 0:
	if k % 10 == 0:
		break
	else:
		k += c
		count += 1
print(count)


n = input()
x = n.split()
for a in range(2):
	x[a] = int(x[a])
for y in range(1, 11):
	d = x[0] * y
	if str(d)[-1] == '0' or str(d)[-1] == str(x[1]):
		break
print(y)


A = input().split()
k = int(A[0])
r = int(A[1])
total = k
count = 1
while total % 10 != r and total % 10 != 0:
	total += k
	count += 1
print(count)


(k, r) = input().split()
k = int(k)
r = int(r)
flag = 0
count = 1
while flag != 1:
	if count * k % 10 == 0 or count * k % 10 == r:
		flag += 1
	else:
		count += 1
print(count)


(k, r) = input().split()
k = int(k)
r = int(r)
n = 0
i = 0
while True:
	n = n + k
	if n - n // 10 * 10 == r or n % 10 == 0:
		break
	i += 1
	continue
print(i + 1)


(k, r) = map(int, input().split())
cnt = 0
_sum = 0
while True:
	cnt += 1
	_sum += k
	rem = _sum % 10
	if rem == r or rem == 0:
		break
print(cnt)


(k, r) = map(int, input().split())
cost = 0
i = 0
flag = 0
while flag == 0:
	i += 1
	h = k * i
	if h % 10 == 0 or h % 10 == r:
		flag = 1
print(i)


(k, r) = map(int, input().split())
s = []
for i in range(1, 11):
	a = k * i
	if a % 10 == 0:
		s.append(i)
	else:
		a -= r
		if a % 10 == 0:
			s.append(i)
answer = min(s)
print(answer)


sum = 0
shovels_bought = 0
vinput = input()
input_list = list(map(int, vinput.split()))
shovel_price = input_list[0]
small_coin = input_list[1]
while sum % 10 != small_coin and (sum % 10 != 0 or sum == 0):
	shovels_bought = shovels_bought + 1
	sum = shovel_price * shovels_bought
print(shovels_bought)


(price, coin) = input().split()
price = int(price)
coin = int(coin)
n = 1
if price % 10 == coin:
	print(1)
else:
	while n * price % 10 != coin and n * price % 10 != 0:
		n += 1
	else:
		print(n)


l = list(map(int, input().split()))
k = l[0]
r = l[1]
q = 0
while True:
	q += 1
	if k * q % 10 == 0 or (k * q - r) % 10 == 0:
		print(q)
		break


(a, b) = map(int, input().split())
i = 1
t = a
j = a // 10
k = a % 10
s = a % 10
while s != 0 and k != b:
	i += 1
	a = t * i
	k = a % 10
	s = a % 10
print(i)


(k, r) = map(int, input().split())
s = k
flag = False
count = 0

def new(k, r):
	s = k
	while s % 10 != 0:
		s += k
	return s // k
while (s - r) % 10 != 0:
	s += k
	count += 1
	if count >= 500:
		ans = new(k, r)
		flag = True
		break
if flag:
	print(ans)
else:
	print(s // k)


(shovel_cost, coin) = [int(x) for x in input().split()]
for i in range(1, 11):
	overall_cost = i * shovel_cost
	if overall_cost % 10 == 0 or (overall_cost - coin) % 10 == 0:
		break
print(i)


y = input()
y = y.split(' ')
y = list(map(lambda x: int(x), y))
shovels = 1
money = 0
bought = 0
while True:
	if money == y[0] * shovels:
		break
	if money < y[0] * shovels:
		money += 10
	if money > y[0] * shovels:
		money -= 10
		money += y[1]
		if money == y[0] * shovels:
			break
		else:
			shovels += 1
			money -= y[1]
print(shovels)


(k, r) = map(int, input().split())
d = 10
i = 1
n = 1
while (k * i - r) % 10 != 0 and k * i % 10 != 0:
	n += 1
	i += 1
print(n)


s = input().split()
a = int(s[0][-1])
b = int(s[1])
for i in range(1, 11):
	if str(i * a)[-1] == str(b) or str(i * a)[-1] == '0':
		print(i)
		break


(k, r) = input().split()
k = int(k)
r = int(r)
c = 0
i = 1
while 1:
	t = i * k
	if t % 10 == r or t % 10 == 0:
		c += 1
		break
	else:
		c += 1
		i += 1
print(c)


l = list(map(int, input().split()))
ans = 1
repet = l[0]
pre = 0
while True and ans < 10:
	if repet % 10 == 0:
		pre = ans
		break
	elif l[0] % 5 == 0:
		if (l[0] - l[1]) % 5 == 0:
			pre = 1
		else:
			pre = 2
		break
		break
	elif repet % 10 == l[1]:
		pre = ans
		break
	repet += l[0]
	ans += 1
print(pre)


(k, r) = map(int, input().split())
a = k
i = 2
while True:
	if k % 10 == 0 or k % 10 == r:
		break
	k = a * i
	i += 1
print(i - 1)


def shovel(lista):
	coins = lista[0]
	temp = coins
	r = lista[1]
	counter = 1
	while True:
		if temp % 10 == 0:
			break
		elif (temp - r) % 10 == 0:
			break
		else:
			temp += coins
			counter += 1
	return counter
inp = list(map(int, input().rstrip().split()))
print(shovel(inp))


(k, r) = map(int, input().split())
l = k
while True:
	if l % 10 == 0 or (l - r) % 10 == 0:
		break
	else:
		l += k
print(l // k)


def main():
	from sys import stdin, stdout
	(k, r) = map(int, input().split())
	n = 0
	ans = int()
	while True:
		if n != 0 and 10 * n % k == 0:
			ans = 10 * n // k
			break
		if (10 * n + r) % k == 0:
			ans = (10 * n + r) // k
			break
		n += 1
	stdout.write(str(ans) + '\n')
main()


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


(k, n) = map(int, input().split(' '))
c = 0
i = 1
while i > 0 and i < 10:
	d = i * k
	if d % 10 == 0:
		c = i
		break
	else:
		h = d % 10
		if h == n:
			c = i
			break
		else:
			i += 1
print(c)


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


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


a = input().split()
k = int(a[0])
r = int(a[1])
x = 1
while True:
	i = x * k
	if i % 10 == r or i % 10 == 0:
		break
	x += 1
print(int(x))


a = input().split()
x = int(a[0])
y = int(a[1])
i = 1
d = 0
while i <= 1000:
	p = x * i
	d = d + 1
	if p % 10 == 0 or p % 10 == y:
		break
	i = i + 1
print(d)


x = [int(i) for i in input().split()]
k = x[0]
r = x[1]
n = 0
found = False
while not found:
	n += 1
	if n * k % 10 == 0 or (n * k - r) % 10 == 0:
		found = True
print(n)


(k, r) = list(map(int, input().split()))
for i in range(1, 1000):
	t = k * i
	if t - r >= 0 and (t - r) % 10 == 0 or t % 10 == 0:
		print(i)
		break


inputs = [int(x) for x in input().split()]
i = 1
while True:
	if inputs[0] * i % 10 == inputs[1] or inputs[0] * i % 10 == 0:
		break
	i += 1
print(i)


(price, coin) = map(int, input().split())
(shovels, all) = (1, price)
while all % 10 != coin:
	if all % 10 == 0:
		break
	shovels += 1
	all = price * shovels
print(shovels)


(k, n) = map(int, input().split())
res = 1
while 0 != res * k % 10 != n:
	res += 1
print(res)


(K, R) = map(int, input().split())
L = 0
J = K
for I in range(10):
	M = str(J)
	if M[-1] == str(R) or M[-1] == '0':
		break
	J += K
print(L + I + 1)


(price, change) = map(int, input().split())
string_price = str(price)
counter = 1
if string_price[len(string_price) - 1] == 0:
	print(price // 10)
else:
	while True:
		multiples = price * counter
		string_multiples = str(multiples)
		if string_multiples[len(string_multiples) - 1] == '0':
			print(counter)
			break
		elif string_multiples[len(string_multiples) - 1] == str(change):
			print(counter)
			break
		counter += 1


showel = 1
mul = 1
(n1, k) = map(int, input().split())
n1 = num = n1 % 10
while not (n1 % 10 == 0 or (n1 - k) % 10 == 0):
	mul += 1
	n1 = num * mul
	showel += 1
print(showel)


(k, r) = map(int, input().split())
l = k
c = 1
b = True
while b:
	if k % 10 == 0 or k % 10 == r:
		b = False
	else:
		c += 1
		k = l * c
print(c)


s = input().split()
a = int(s[0])
b = int(s[1])
x1 = 1
x2 = 1
while a * x1 % 10 - b != 0 and x1 < 11:
	x1 = x1 + 1
while a * x2 % 10 != 0:
	x2 = x2 + 1
if x1 > x2:
	print(x2)
else:
	print(x1)


(k, r) = map(int, input().split())
x = 0
for i in range(k, 10 ** 5, k):
	b = i % 10
	x += 1
	if b - r == 0 or b == 0:
		print(x)
		break


while True:
	try:
		(k, r) = map(int, input().strip().split())
		res = -1
		for i in range(1, 10):
			if i * k % 10 == r:
				res = i
				break
			if i * k % 10 == 0:
				res = i
				break
		print(res)
	except EOFError:
		break


t = input().split(' ')
t1 = int(t[0])
t2 = int(t[1])
f = 0
i = 1
while 1:
	if t1 * i % 10 == 0 or t1 * i % 10 - t2 == 0:
		f = 1
		break
	i += 1
print(i)


l1 = [int(num) for num in input().split(' ')]
n = 1
while l1[0] * n % 10 != l1[1] and l1[0] * n % 10 != 0:
	n += 1
print(n)


(n, r) = tuple(map(int, input().split()))
if n % 10 == 0:
	print(1)
else:
	i = 1
	while (i * n - r) % 10 != 0:
		if i * n % 10 == 0:
			break
		i += 1
	print(i)


(k, r) = map(int, input().split())
b = 10
n = 0
s = 0
while s == n * k:
	n = n + 1
	s = k * n
	if s % b == 0 or s % b == r:
		break
	else:
		continue
print(n)


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


scanner = lambda : map(int, input().split())
(k, r) = scanner()
flag = False
res = 1
k1 = k
while flag != True:
	if (k - r) % 10 == 0 or k % 10 == 0:
		flag = True
	else:
		res = res + 1
		k = k + k1
print(res)


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


(k, n) = [int(x) for x in input().split()]
for i in range(1, 10):
	if (k * i - n) % 10 == 0:
		print(i)
		break
	elif k * i % 10 == 0:
		print(i)
		break


(k, r) = input().split()
k = int(k)
r = int(r)
i = 1
while True:
	if i * k % 10 in [r, 0]:
		minm = i
		break
	else:
		i = i + 1
print(minm)


(k, r) = map(int, input().split())
if (k - r) % 10 == 0 or k % 10 == 0:
	print(1)
else:
	x = k
	for i in range(2, 1000000):
		x = k * i
		if (x - r) % 10 == 0 or x % 10 == 0:
			print(i)
			break


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


a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
c = a[0]
i = 1
while i <= 10:
	if a[0] % 10 == 0 or (a[0] - a[1]) % 10 == 0:
		print(i)
		i = 100
	else:
		a[0] = c + a[0]
	i = i + 1


import math
from fractions import Fraction as frac
MOD = 1000000000.0 + 7

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 solve(case_no):
	(a, b) = map(int, input().split())
	ans = 0
	while True:
		ans += 1
		if a * ans % 10 == b or a * ans % 10 == 0:
			print(ans)
			exit()
t = 1
for i in range(1, t + 1):
	solve(i)


import sys
from random import choice, randint
inp = sys.stdin.readline
out = sys.stdout.write
flsh = sys.stdout.flush
sys.setrecursionlimit(10 ** 9)
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 MI():
	return map(int, inp().strip().split())

def LI():
	return list(map(int, inp().strip().split()))

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

def LI_():
	return [int(x) - 1 for x in inp().strip().split()]

def LF():
	return [float(x) for x in inp().strip().split()]

def LS():
	return inp().strip().split()

def I():
	return int(inp().strip())

def F():
	return float(inp().strip())

def S():
	return inp().strip()

def pf(s):
	return out(s + '\n')

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	(k, r) = MI()
	i = str(k)[-1]
	c = 1
	while i[-1] != str(r) and i[-1] != '0':
		c += 1
		i = str(int(str(k)[-1]) * c)
	pf(str(c))
main()


import sys
(k, r) = [int(num) for num in sys.stdin.readline()[:-1].split()]
output = 1
while output * k % 10 != 0 and output * k % 10 != r:
	output += 1
print(output)


text = input()
k = int(text.split(' ')[0])
r = int(text.split(' ')[1])
i = 1
while True:
	tmp = k * i
	if tmp % 10 == r or tmp % 10 == 0:
		print(i)
		break
	i += 1


xyz = input()
xyz = xyz.split()
(k, r) = (int(xyz[0], 10), int(xyz[1], 10))
for i in range(1, 11):
	sum = i * k
	if sum % 10 is 0:
		print(i)
		break
	elif (sum - r) % 10 is 0:
		print(i)
		break


(k, r) = input().split()
k = int(k)
r = int(r)
change = r
output = 0
while k * output % 10 != change:
	output += 1
	if k * output % 10 == 0:
		break
print(output)


x = input()
x = list(map(int, x.strip().split()))
orig = x[0]
temp2 = x[1]
sum = orig
for i in range(1, 10):
	if sum % 10 == temp2 or sum % 10 == 0:
		print(str(i))
		break
	else:
		sum = orig * (i + 1)


(k, r) = map(int, input().split())
e = 1
j = 1
while e > 0:
	e = min((j * k - r) % 10, j * k % 10)
	j += 1
print(j - 1)


data = input().split()
price = int(data[0])
for i in range(1, 10):
	data[0] = price
	data[0] = data[0] * i
	if data[0] % 10 == 0 or data[0] % 10 == int(data[1]):
		break
print(i)


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter
from itertools import permutations

def si():
	return str(stdin.readline())

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

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

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

def debug(x):
	return stdout.write(str(x))
(a, b) = mi()
for i in range(1, 1000):
	if (i * a - b) % 10 == 0:
		print(i)
		break
	elif i * a % 10 == 0:
		print(i)
		break


(priceShovel, coin) = [int(x) for x in input().split()]
priceShovel = priceShovel % 10
foundStep1 = 10
for i in range(1, 10):
	if priceShovel * i % 10 - coin == 0:
		foundStep1 = i
		break
for i in range(0, 10):
	if priceShovel == i:
		if priceShovel == 0:
			foundStep2 = 1
		elif priceShovel % 2 == 0:
			foundStep2 = 5
		elif priceShovel == 5:
			foundStep2 = 2
		else:
			foundStep2 = 10
if foundStep1 < foundStep2:
	print(foundStep1)
else:
	print(foundStep2)


(k, r) = map(int, input().split())
j = 1
while j * k % 10 != r:
	if not j * k % 10:
		break
	else:
		j += 1
print(j)


(n, k) = map(int, input().split(' '))
n %= 10
cou = 0
for i in range(1, 10):
	if n * i % 10 == k or n * i % 10 == 0:
		cou = i
		break
	else:
		pass
print(cou)


(p, r) = map(int, input().split())
for i in range(1, 11):
	if i * p % 10 == r or i * p % 10 == 0:
		print(i)
		exit()


(z, r) = map(int, input().split())
x = z
while x % 10 and x % 10 - r:
	x += z
print(x // z)


(k, t) = map(int, input().split())
d = k % 10
k = d
c = 1
while not k == t and (not k % 10 == 0):
	k = (k + d) % 10
	c += 1
print(c)


(k, r) = list(map(int, input().split()))
result = 0

def can_buy_without_change(price):
	return price % 10 == 0 or (price - r) % 10 == 0
while True:
	result += 1
	if can_buy_without_change(result * k):
		break
print(result)


__author__ = 'artyom'

def main():
	(k, r) = read(3)
	x = k
	for i in range(1, 11):
		if x % 10 == 0 or (x - r) % 10 == 0:
			return i
		x += k

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
res = main()
write(res)


def BuyAShovel():
	(price, r) = map(int, input().strip().split())
	shovels = 0
	for i in range(1, 10):
		if not price * i % 10 or not (price * i - r) % 10:
			return i
a = BuyAShovel()
print(a)


(price, burkle) = map(int, input().split())
count = 1
while (price * count - burkle) % 10 != 0 and price * count % 10 != 0:
	count += 1
	if count == 10:
		break
print(count)


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


(price, coin) = map(int, input().split())
i = 1
while True:
	total = price * i
	if total % 10 == 0 or total % 10 == coin:
		print(i)
		break
	i += 1


i = []
(k, r) = map(int, input().split())
for x in range(1, 10):
	y_1 = k * x
	y_2 = y_1 % 10
	if y_2 == 0:
		i.append(int(x))
	elif y_2 == r:
		i.append(int(x))
m = min(i)
print(m)


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


def compute(k, r):
	for i in range(1, 100):
		if (k * i - r) % 10 == 0:
			return i
	return None
(k, r) = map(int, input().split())
print(min(compute(k, r) or 10 ** 10, compute(k, 0)))


two = input().split()
(k, r) = [int(item) for item in two]
shovel = 1
q = k
while True:
	if k % 10 != r and k % 10 != 0:
		shovel += 1
		k += q
	else:
		break
print(shovel)


import math

def getAns(k, r):
	totCount = 0
	i = 1
	while i <= 9:
		if i * k % 10 == r or i * k % 10 == 0:
			return i
		i += 1
	return 10
(k, r) = [int(x) for x in input().split()]
print(getAns(k, r))


def main():
	(k, r) = map(int, input().split())
	ans = 1
	while True:
		x = ans * k % 10
		if not x or x == r:
			print(ans)
			return
		ans += 1
	pass
main()


(K, R) = map(int, input().split())
ans = 1
while K * ans % 10 != 0 and (K * ans - R) % 10 != 0:
	ans += 1
print(ans)


(k, r) = input().split()
(k, r) = (int(k), int(r))
for shvls in range(1, 100):
	if shvls * k % 10 == r or shvls * k % 10 == 0:
		print(shvls)
		break


(k, r) = map(int, input().split())
for x in range(1, 11):
	if k * x % 10 in {0, r}:
		print(x)
		break


import math
(k, r) = map(int, input().split())
cnt = 1
if r % k == 0:
	print(r // k)
elif k % 10 == 0:
	print(1)
else:
	while cnt * k % 10 and cnt * k % 10 != r:
		cnt += 1
	print(cnt)


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


(k, r) = input().split()
k = int(k)
r = int(r)
c = 1
while 0 != k * c % 10 != r:
	c += 1
print(c)


(n, k) = map(int, input().split())
c = 1
while 1:
	if c * n % 10 == 0 or c * n % 10 == k:
		print(c)
		break
	c += 1


(k, m) = map(int, input().split())
for i in range(1, 10000):
	if k * i % 10 == m or k * i % 10 == 0:
		print(i)
		break


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(k, r) = get_list()
temp = k
count = 1
while True:
	if temp % 10 == 0:
		print(count)
		break
	elif (temp - r) % 10 == 0:
		print(count)
		break
	elif temp == r:
		print(count)
		break
	else:
		temp = temp + k
		count += 1


(price, rem) = input().split()
price = int(price)
rem = int(rem)
i = 1
while i != 10:
	new = i * price
	if new % 10 == 0:
		print(i)
		break
	elif (new - rem) % 10 == 0:
		print(i)
		break
	i = i + 1


def test75_1(x, y, z):
	if x % 10 != y and x <= 10 * z:
		return test75_1(x + z, y, z)
	else:
		return int(x / z)
(price, change) = [int(x) for x in input().strip().split(' ')]
print(min(test75_1(price, change, price), test75_1(price, 0, price)))


(k, r) = map(int, input().split())
a = e = k % 10
C = 1
while a != r and a != 0:
	a = (a + e) % 10
	C += 1
print(C)


(k, r) = map(int, input().split(' '))
item = 1
res = k
if k % 10 == r:
	print(1)
else:
	while res % 10 != r and res % 10 != 0:
		item += 1
		res = k * item
	print(item)


def ten(n, k):
	count = 1
	index = 2
	while True:
		if n % 10 == 0 or (n - k) % 10 == 0:
			return count
		else:
			n = n // (index - 1)
			number = n * index
			n = number
			count = count + 1
		index = index + 1
(n, k) = map(int, input().split())
print(ten(n, k))


a = list(map(int, input().strip().split()))[:2]
k = a[0]
r = a[1]
for i in range(1, 11):
	checkval = k * i
	if checkval % 10 == r or checkval % 10 == 0:
		print(i)
		break


(k, r) = list(map(int, input().split()))
m1 = 10
for m in range(10, 0, -1):
	a = m * k
	if a % 10 == 0 or a % 10 == r:
		m1 = m
print(m1)


def ge(num):
	return num - 10 * int(num / 10)
num = 1
(k, r) = [int(x) for x in input().split()]
if ge(k) == 0:
	print(1)
elif ge(k) == r:
	print(1)
elif ge(k) == 5:
	print(2)
else:
	while ge(num * k) != r and ge(num * k) != 0:
		num += 1
	print(num)


(n, k) = [int(i) for i in input().split(' ')]
p = 10
t = False
if k >= n and k % n == 0:
	t = True
	print(k // n)
for i in range(1, 1000):
	if t:
		break
	x = p * i
	y = p * i + k
	if x % n == 0:
		print(x // n)
		break
	if y % n == 0:
		print(y // n)
		break


import sys
import math
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

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

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

def Solution(n, k):
	for i in range(1, 11):
		tmp = n * i
		if tmp % 10 == 0 or tmp % 10 == k:
			print(i)
			return

def main():
	(n, k) = get_ints_in_variables()
	Solution(n, k)
main()


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


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


(k, r) = map(int, input().split())
for i in range(1, 10):
	j = k
	j = j * i
	o = j - r
	if o % 10 == 0:
		print(i)
		break
	if j % 10 == 0:
		print(i)
		break


(p, k) = map(int, input().split())
for i in range(1, 1000):
	l = p * i
	q = l % 10
	if q == k or q == 0:
		print(i)
		break


n = input()
d = []
d = n.split()
k = int(d[0])
r = int(d[1])
red = True
j = 1
while red:
	sm = k * j
	if sm % 10 == 0:
		print(f'{j} ')
		break
	if (sm - r) % 10 == 0:
		print(f'{j}  ')
		break
	j += 1


(a, b) = input().split()
i = 0
while 1:
	i += 1
	d = int(a) * i
	if d % 10 == int(b) or d % 10 == 0:
		print(i)
		break


(price, coin) = map(int, input().split())
(shovel, all) = (1, price)
while all % 10 != coin:
	if all % 10 == 0:
		break
	all = price * shovel
	shovel += 1
print(shovel - 1 if all != price else 1)


(x, y) = map(int, input().split())
h = 1
i = 0
b = True
while b:
	i += 1
	h = x * i
	if h % 10 == 0 or h % 10 == y:
		b = False
print(i)


st = input()
fields = st.split(' ')
k = float(fields[0])
r = float(fields[1])
x = 10.0
i = 1
while k * i % x != 0 and k * i % x != r:
	i += 1
print(i)


(k, r) = (int(x) for x in input().split())

def num_shovs(cost, coin):
	n_shovs = 1
	while True:
		if (n_shovs * cost - coin) % 10 == 0 or n_shovs * cost % 10 == 0:
			return n_shovs
		n_shovs += 1
print(num_shovs(k, r))


(price, p) = list(map(int, input().split(' ')))
count = int(1)
sumV = price
temp = True
while temp:
	tempVal = sumV % int(10)
	if tempVal == int(0) or tempVal == p:
		break
	count += int(1)
	sumV += price
print(count)


import math
(k, t) = map(int, input().split())
k_new = k - int(k // 10) * 10
for i in range(1, 10):
	if i * k_new % 10 == 0 or (i * k_new - t) % 10 == 0:
		print(i)
		break


def func(k, r):
	rem = {0, r}
	i = 1
	while True:
		mod = i * k % 10
		if mod in rem:
			return i
		else:
			i += 1
(k, r) = map(int, input().split())
print(func(k, r))


(p, ch) = map(int, input().split())
num = 1
while True:
	if num * p % 10 == ch or num * p % 10 == 0:
		print(num)
		break
	else:
		num += 1


(n, r) = map(int, input().split())
sum = n
c = 1
while sum % 10 != r and sum % 10 != 0:
	sum += n
	c += 1
print(c)


krStr = input()
k = int(krStr.split()[0])
r = int(krStr.split()[1])
if r % k == 0:
	print(r // k)
	quit()
i = 1
ans = 0
while 1:
	if i * 10 % k == 0:
		ans = i * 10 // k
		break
	if (i * 10 + r) % k == 0:
		ans = (i * 10 + r) // k
		break
	i = i + 1
print(ans)


(k, r) = map(str, input().split())
if k[-1] == r:
	print(1)
elif k[-1] == '0':
	print(1)
elif k[-1] == '5':
	print(2)
else:
	k = int(k)
	for i in range(2, 10):
		x = str(k * i)
		if x[-1] == r:
			print(i)
			break
		if x[-1] == '0':
			print(i)
			break


(k, r) = map(int, input().split())
x = y = z = 1001
for i in range(1, 1001):
	if r % k == 0:
		z = r / k
		break
	if 10 * i % k == 0:
		x = 10 * i / k
		break
	if (10 * i + r) % k == 0:
		y = (10 * i + r) / k
		break
print(int(min(x, y, z, 10)))


(n, m) = [int(x) for x in input().split()]
res = 1
val = 0
while val == 0 or (val % 10 != 0 and val % 10 != m):
	val = n * res
	res += 1
print(res - 1)


list1 = list(input().strip().split(' '))
i = 1
while 1:
	if (i * int(list1[0]) - int(list1[1])) % 10 == 0 or i * int(list1[0]) % 10 == 0:
		print(i)
		break
	i += 1


mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 4, 6, 8, 0, 2, 4, 6, 8, 0], [3, 6, 9, 2, 5, 8, 1, 4, 7, 0], [4, 8, 2, 6, 0, 4, 8, 2, 6, 0], [5, 0, 5, 0, 5, 0, 5, 0, 5, 0], [6, 2, 8, 4, 0, 6, 2, 8, 4, 0], [7, 4, 1, 8, 5, 2, 9, 6, 3, 0], [8, 6, 4, 2, 0, 8, 6, 4, 2, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]
(k, r) = map(int, input().split())
k = k % 10
if k == 0:
	print(1)
else:
	ans = -1
	for i in range(10):
		if r == mat[k - 1][i] or mat[k - 1][i] == 0:
			ans = i + 1
			break
	if ans == -1:
		ans = 10
	print(ans)


(lop, moneta) = map(int, input().split())
it = 1
itog = lop
while itog % 10 != 0:
	if itog % 10 == moneta:
		break
	it = it + 1
	itog = itog + lop
print(it)


(k, r) = map(int, input().split())
found = False
i = 0
while not found:
	i += 1
	c = i * k
	if c % 10 == 0 or c % 10 == r:
		found = True
print(i)


(x, y) = list(map(int, input().split()))
f = x
b = 1
while True:
	if (x - y) % 10 == 0:
		print(b)
		break
	elif x % 10 == 0:
		print(b)
		break
	else:
		x += f
		b += 1
		continue


(each, r) = map(int, input().split())
ans = 1
for _ in range(10000000):
	cost = each * ans
	if cost % 10 == 0 or cost % 10 == r:
		print(ans)
		break
	ans += 1


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


(k, r) = [int(var) for var in input().split()]
initial_value = k
count = 0
while True:
	count += 1
	remain = k % 10
	if remain == r or remain == 0:
		break
	k += initial_value
print(count)


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


kr = list(map(int, input().split()))
shovels = 1
while shovels > 0:
	if kr[0] * shovels % 10 == 0 or kr[0] * shovels % 10 == kr[1]:
		break
	shovels += 1
print(shovels)


def main():
	(a, b) = [int(v) for v in input().split()]
	for i in range(1, 11):
		if a * i % 10 == 0 or (a * i - b) % 10 == 0:
			print(i)
			return
main()


(priceOfShovel, r) = [int(s) for s in input().split()]
shovels = 1
while True:
	if shovels * priceOfShovel % 10 == 0:
		break
	if (shovels * priceOfShovel - r) % 10 == 0:
		break
	shovels += 1
print(shovels)


x = input('').split()
for c in range(1, 1000):
	if (int(x[0]) * c - int(x[1])) / 10 == int((int(x[0]) * c - int(x[1])) / 10) or int(x[0]) * c / 10 == int(int(x[0]) * c / 10):
		print(c)
		break


(a, b) = map(int, input().split())
c = 0
d = 0
if a % 10 == 0:
	print(1)
elif a % 5 == 0 and b % 5 == 0:
	print(1)
elif a % 5 == 0:
	print(2)
elif a % 2 == 0 and b % 2 == 1:
	print(5)
elif a % 2 == 0 and b % 2 == 0:
	a = str(a)
	c = int(a[len(a) - 1])
	for i in range(10):
		c = int(c)
		d = c * i
		d = str(d)
		d = d[len(d) - 1]
		d = int(d)
		if d == b:
			print(i)
			break
else:
	for i in range(10):
		a = str(a)
		c = a[len(a) - 1]
		c = int(c)
		d = c * i
		d = str(d)
		d = d[len(d) - 1]
		d = int(d)
		if d == b:
			print(i)
			break


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


(n, extra) = map(int, input().strip().split())
x = 1
while True:
	if n * x % 10 == 0:
		print(x)
		break
	elif (n * x - extra) % 10 == 0:
		print(x)
		break
	x += 1


(k, n) = [int(x) for x in input().split()]
x = k
count = 1
while True:
	if x % 10 == 0 or x % 10 == n:
		break
	else:
		count += 1
		x = k * count
print(count)


(k, r) = map(int, input().split())
m = 1
flag = 0
while flag == 0:
	total = m * k
	total = total % 10
	if total % r == 0 and total // r == 1:
		flag = 1
		break
	if total == 0:
		flag = 1
		break
	m += 1
print(m)


(n, k) = map(int, input().split())
s = 1
d = n
while n % 10 != k and n % 10 != 0:
	n += d
	s += 1
print(s)


word = str(input())
word = word.split(' ')
cost = int(word[0])
deno = int(word[1])
hm = 1
x = False
while x == False:
	if (cost * hm - deno) % 10 == 0:
		x = True
		hm = hm - 1
	elif cost * hm % 10 == 0:
		x = True
		hm = hm - 1
	hm += 1
print(hm)


(k, r) = map(int, input().split(' '))
n = 1
good = True
while good:
	if n * k % 10 == 0 or n * k % 10 == r:
		print(n)
		good = False
	else:
		n += 1


(k, r) = map(int, input().split(' '))
res = 1
f = 0
f += k
while f % 10 != r and f % 10 != 0:
	f += k
	res += 1
print(res)


temp = input().strip().split()
price = int(temp[0])
coin = int(temp[1])
cur_price = price
count = 1
while True:
	cur_price = price * count
	if cur_price % 10 == 0:
		break
	if (cur_price - coin) % 10 == 0:
		break
	if cur_price % 10 == coin:
		break
	count += 1
print(count)


s = input().split(' ')
k = int(s[0])
r = int(s[1])
count = 1
while True:
	if k * count % 10 == 0 or k * count % 10 == r:
		break
	count += 1
print(count)


(cost, r) = map(int, input().split())
i = 1
ans = -1
newcost = 1
while i < 10:
	newcost = cost * i
	if newcost % 10 == 0 or newcost % 10 == r:
		ans = i
		break
	i += 1
if ans == -1:
	print(10)
else:
	print(ans)


(k, r) = map(int, input().split())
s = str(k)
s = int(s[len(s) - 1])
w = s
i = 1
q = str(w)
while q[len(q) - 1] != str(r) or w % 10 != 0:
	if q[len(q) - 1] == str(r) or w % 10 == 0:
		break
	w += s
	q = str(w)
	i += 1
print(i)


def shovel(k, r):
	if k % 10 == 0:
		return 1
	last_digit = k % 10
	for i in range(1, 10):
		if last_digit * i % 10 == r:
			break
	if k % 5 == 0:
		i = min(i, 2)
	elif k % 2 == 0:
		i = min(i, 5)
	return i
(k, r) = list(map(int, input().strip().split()))
print(shovel(k, r))


(n, k) = map(int, input().split())
if n == 1 and k != 1:
	print(k)
else:
	i = 1
	while i <= 10000000:
		if i * n % 10 == k:
			print(i)
			break
		elif i * n % 10 == 0:
			print(i)
			break
		i += 1


(a, b) = map(int, input().split())
z = 1
A = a
while True:
	if A % 10 == b or A % 10 == 0:
		print(z)
		break
	else:
		A = A + a
		z += 1


import sys
import math
from statistics import mean
from collections import Counter
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
(k, r) = invr()
a = k
j = 1
flag = True
while flag:
	if k % 10 == 0 or k % 10 == r:
		break
	else:
		k = k + a
		j = j + 1
print(j)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

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

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

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 solve(case):
	(n, k) = sep()
	i = 1
	while n * i % 10 != k and n * i % 10 != 0:
		i += 1
	print(i)
testcase(1)


(k, r) = [int(x) for x in input().split()]
s = k
count = 1
while True:
	if s % 10 == 0 or s % 10 == r:
		break
	s += k
	count += 1
print(count)


line = input().split(' ')
price = int(line[0])
khuchra = int(line[1])
i = 1
while i < 10:
	if price * i % 10 == 0 or (price * i - khuchra) % 10 == 0:
		print(i)
		exit()
	i += 1
print(10)


(k, r) = map(int, input().split())
y = 1
while True:
	if y * k % 10 == 0:
		print(y)
		break
	if y * k % 10 == r:
		print(y)
		break
	y += 1


(k, r) = map(int, input().split())
x = 0
i = 1
count = 0
while x != 1:
	a = k * i
	b = a % 10
	if b == 0:
		count += 1
		break
	c = b / r
	x = c
	i += 1
	count += 1
print(count)


(n, m) = (int(i) for i in input().split())
ans = 10
for i in range(1, 10):
	if (n * i - m) % 10 == 0 or n * i % 10 == 0:
		ans = min(ans, i)
print(ans)


def numshovels(price, spare_coin_denom):
	for i in range(1, 11):
		spare_needed = i * price % 10
		if spare_needed in [0, spare_coin_denom]:
			return i
(a, b) = input().split(' ')
print(numshovels(int(a), int(b)))


(n, k) = map(int, input().split())
shovels = 1
while True:
	tot = shovels * n
	t = tot % 10
	if t == 0:
		print(shovels)
		break
	if k == t:
		print(shovels)
		break
	shovels += 1


I = lambda : map(int, input().split())
(p, k) = I()
ans = 1
s = p
while s % 10 != 0 and (s - k) % 10 != 0:
	ans += 1
	s += p
print(ans)


import sys
(k, r) = map(int, input().split())
medzi = 0
for x in range(1, sys.maxsize ** 10):
	medzi = x * k
	if medzi % 10 == 0 or (medzi - r) % 10 == 0:
		print(x)
		break


(k, r) = [int(i) for i in input().split()]
count = 1
total = k
while total % 10 != r and total % 10 != 0:
	count += 1
	total += k
print(count)


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


(n, k) = [int(i) for i in input().split()]
g = n
while True:
	if n % 10 == 0:
		break
	if (n - k) % 10 == 0:
		break
	n += g
print(n // g)


(n, k) = map(int, input().split())
i = 1
while i * n % 10 != k:
	if i * n % 10 == 0:
		break
	i += 1
print(i)


(k, r) = list(map(int, input().split(' ')))
tens = 10
min_count = 0
threshold = 10
for i in range(threshold):
	costs_by_count = (i + 1) * k
	if (costs_by_count - r) % 10 == 0 or costs_by_count % 10 == 0:
		print(i + 1)
		break
else:
	print(threshold)


(p, q) = map(int, input().split())
pp = p
i = 1
while pp % 10 != q and pp % 10 != 0:
	pp += p
	i += 1
print(i)


(k, r) = [int(x) for x in input().split()]
s = 1
while not (s * k % 10 == r or s * k % 10 == 0):
	s += 1
print(s)


input_arr = list(map(int, input().rstrip().split()))
shovel_price = input_arr[0]
r = input_arr[1]
rest_change = shovel_price % 10
min_shovels = 0
for i in range(1, 10):
	if i * rest_change % r == 0 or i * rest_change % 10 == r or i * rest_change % 10 == 0:
		if i * shovel_price % 10 == r:
			min_shovels = i
			break
		elif i * shovel_price % 10 == 0:
			min_shovels = i
			break
print(min_shovels)


(shovle, cent) = map(int, input().split())
shovle1 = shovle
if shovle % 10 == cent or shovle % 10 == 0:
	print(1)
elif shovle % 10 != cent or shovle % 10 == 0:
	while shovle1 % 10 != cent and shovle1 % 10 != 0:
		shovle1 = shovle1 + shovle
	print(shovle1 // shovle)


n = list(map(int, input().split(' ')))
for i in range(1, 10):
	k = n[0] * i
	if k % 10 == n[1]:
		k = i
		break
	elif k % 10 == 0:
		k = i
		break
	else:
		k = 10
print(k)


def shovel():
	inp = list(map(int, input().strip().split()))
	counter = 1
	cost = inp[0]
	change = inp[1]
	while counter != 10:
		if cost % 10 == 0 or (cost - change) % 10 == 0:
			break
		cost += inp[0]
		counter += 1
	return counter
print(shovel())


(k, r) = input().split()
num = 0
for i in range(1, 10):
	res = i * int(k)
	if res % 10 == 0:
		num += 1
		break
	elif res % 10 == int(r):
		num += 1
		break
	else:
		num += 1
print(num)


def main():
	(k, r) = list(map(int, input().split()))
	for x in range(1, 11):
		if k * x % 10 == 0 or k * x % 10 == r:
			return x
print(main())


import math
import itertools
gh = lambda : map(int, input().split())
mod = 998244353
mod = int(mod)

def main():
	(k, r) = gh()
	for i in range(1, int(10000.0) + 1):
		if (k * i - r) % 10 == 0 or k * i % 10 == 0 or type(k * i / r) == 'int':
			print(i)
			return
main()


input_s = input().split(' ')
k = int(input_s[0])
r = int(input_s[1])
i = 1
while 1 == 1:
	result = k * i % 10
	if result == 0 or result == r:
		break
	i += 1
print(i)


(k, r) = input().split()
k = int(k)
count = 1
test = k
while True:
	if str(test)[-1] == r or str(test)[-1] == '0':
		break
	test += k
	count += 1
print(count)


masuk = input().split()
Belum = True
b = 1
while Belum:
	if b * int(masuk[0]) % 10 == int(masuk[1]) or b * int(masuk[0]) % 10 == 0:
		hasil = b
		Belum = False
	else:
		b += 1
print(hasil)


dc = 10

def qs(p, r):
	for x in range(1, dc + 1):
		if not (x * p - r) % dc or not x * p % dc:
			return x
(p, r) = [int(x) for x in input().split()]
print(qs(p, r))


(price, coins) = map(int, input().split())
x = 1
while True:
	if price * x / 10 == int(price * x / 10):
		print(x)
		break
	elif (price * x - coins) / 10 == int((price * x - coins) / 10):
		print(x)
		break
	else:
		x += 1


inp = input().split()
price = int(inp[0])
rCoin = int(inp[1])
pricesList = []
n = 1
while True:
	maxTotal = n * price - rCoin
	if maxTotal % 10 == 0 or n * price % 10 == 0:
		pricesList.append(maxTotal + rCoin)
		break
	n += 1
print(pricesList[0] // price)


def solve(f):
	k = f[0]
	r = f[1]
	for i in range(1, 1001):
		if i * k % 10 == r or i * k % 10 == 0:
			print(i)
			break

def main():
	solve([int(x) for x in input().split()])
main()


ln = input().split(' ')
k = int(ln[0])
r = int(ln[1])
p = 1
while k * p % 10 != r and k * p % 10 != 0:
	p += 1
print(p)


line = list(map(int, input().split()))
price = line[0]
r = line[1]
for i in range(1, 10):
	if price * i % 10 == r or price * i % 10 == 0:
		print(i)
		break


(n, k) = map(int, input().split())
c = 0
i = 2
n1 = n
while 1:
	if n1 % 10 == k or n1 % 10 == 0:
		c += 1
		break
	else:
		n1 = n
		n1 *= i
		c += 1
		i += 1
		if n1 % 10 == k or n1 % 10 == 0:
			c += 1
			break
print(c)


data = list(map(int, input().split()))
cena = data[0]
r = data[1]
lop = 0
lopats = 1
while lopats <= 10:
	if lopats * cena % 10 == 0 or lopats * cena % 10 == r:
		lop = lopats
		break
	lopats = lopats + 1
print(lop)


a = list((int(x) for x in input().split()))
for i in range(1, 11):
	if a[0] * i % 10 == 0 or a[0] * i % 10 == a[1]:
		print(i)
		break
	else:
		continue


(price_shovel, coin_value_exception) = map(int, input().split())
contador = 0
while True:
	contador += 1
	shovels_prices = price_shovel * contador
	if shovels_prices % 10 == 0:
		break
	elif str(shovels_prices)[-1] == str(coin_value_exception):
		break
print(contador)


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split().strip())
M = lambda : map(int, input().split())
(n, r) = M()
for i in range(1, 10):
	if i * n % 10 == 0:
		print(i)
		break
	elif n * i % 10 == r:
		print(i)
		break


(price, add) = map(int, input().split())
counter = 1
while counter * price % 10 != add and counter * price % 10 != 0:
	counter += 1
print(counter)


def buy_a_shovel():
	data = [int(x) for x in input().strip().split(' ')]
	number = 0
	total_sum = 0
	while True:
		total_sum += data[0]
		number += 1
		if total_sum % 10 == data[1] or total_sum % 10 == 0:
			return number
print(buy_a_shovel())


kr = input()
(k, r) = (int(i) for i in kr.split())
ans = 0
if k % 5 == 0 and k % 10 != 0:
	ans = 2
elif k % 10 == 0:
	ans = 1
elif k % 2 == 0 and r % 2 != 0:
	ans = 5
for i in range(1, 10):
	if k * i % 10 == r:
		ans = i
		break
print(ans)


(K, r) = map(int, input().split())
s = 1
while True:
	if K * s % 10 == r or K * s % 10 == 0:
		print(s)
		break
	s += 1


(K, R) = list(map(int, input().split()))
for M in range(1, 11):
	P = M * K
	if P % 10 == 0 or (P - R) % 10 == 0:
		print(M)
		break


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
ans = 1
z = n
while n % 10 != 0 and n % 10 != m:
	ans += 1
	n += z
print(ans)


inp = input().split(' ')
price = int(inp[0])
coin = int(inp[1])
for i in range(1, 10):
	if price * i % 10 == coin or price * i % 10 == 0:
		print(i)
		break


(k, r) = map(int, input().split())
j = 1
tmp = k
for i in range(11):
	if k % 10 == 0 or k % 10 == r:
		break
	else:
		j += 1
		k += tmp
print(j)


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


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
(k, r) = mi()
for i in range(1, 11):
	a = k * i
	if a % 10 == 0 or a % 10 == r:
		print(i)
		break


(n, k) = map(int, input().strip().split())
i = 1
while True:
	temp = n * i
	if temp % 10 == 0 or temp % 10 == k:
		break
	i += 1
print(i)


(n, r) = [int(i) for i in input().split(' ')]
result = 1
while n * result % 10 != r and n * result % 10 != 0:
	result += 1
print(result)


(k, r) = map(int, input().split())
lastnumber = int(str(k)[-1])
for i in range(1, 10):
	a = str(lastnumber * i)[-1]
	if int(a) == 0:
		print(i)
		break
	elif int(a) == r:
		print(i)
		break


(k, r) = list(map(int, input().split()))
x = k % 10
i = 1
while 1:
	s = x * i
	if s % 10 == r or s % 10 == 0:
		print(i)
		break
	i = i + 1


s = input().split(' ')
n = int(s[0]) % 10
r = int(s[1])
i = 1
while True:
	p = n * i % 10
	if p == 0 or p == r:
		print(i)
		break
	else:
		i += 1


num = input()
r1 = num.split(' ')
k = int(r1[0])
r = int(r1[1])
n = 10
i = 1
while True:
	if (k * i - r) % n == 0 or k * i % n == 0:
		break
	else:
		i = i + 1
print(i)


def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as c

def solve():
	(K, R) = getInts()
	tmp = K
	j = 1
	while True:
		if tmp % 10 in (R, 0):
			return j
		j += 1
		tmp += K
ans = solve()
print(ans)


(k, r) = list(map(int, input().split()))
for i in range(1, 1000000000):
	if k * i % 10 == r:
		print(i)
		break
	elif k * i % 10 == 0:
		print(i)
		break


(k, r) = list(map(int, input().split()))
for i in range(1, 10):
	shovel = str(k * i)
	if shovel[len(shovel) - 1] == '0' or shovel[len(shovel) - 1] == str(r):
		print(i)
		break


(price, remainder) = map(int, input().split())
n = price
shovels = 1
while (n - remainder) % 10 > 0 and n % 10 > 0:
	n += price
	shovels += 1
print(shovels)


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


(price, coins) = map(int, input().split(' '))
minimum = 1
done = False
while not done:
	if price * minimum % 10 == 0:
		done = True
		break
	elif price * minimum % 10 == coins:
		done = True
		break
	minimum += 1
print(minimum)


(k, r) = [int(item) for item in input().split()]
n = 1
while n * k % 10 != 0 and n * k % 10 != r:
	n += 1
print(n)


(k, r) = map(int, input().split())
start = k
shovels = 1
while int(str(k)[-1]) != r and k % 10 != 0:
	shovels += 1
	k = start * shovels
print(shovels)


(n, k) = map(int, input().split())
b = True
d = 0
d = d + n
c = 0
while b:
	if d % 10 == 0:
		c = c + 1
		b = False
	elif (d - k) % 10 == 0:
		c = c + 1
		b = False
	elif (d - k) % 10 != 0:
		d = d + n
		c = c + 1
	else:
		continue
print(c)


(a, b) = map(int, input().split())
last = 0
c = 0
while True:
	last += a
	c += 1
	if last % 10 == 0:
		print(c)
		break
	elif last % 10 - b == 0:
		print(c)
		break


def s():
	(k, r) = [int(x) for x in input().split(' ')]
	ans = 1
	while 1:
		if k * ans % 10 == 0:
			break
		elif k * ans % 10 != r:
			ans += 1
		else:
			break
	print(ans)
s()


z = list(map(int, input().split()))
count = 0
i = 1
while (i * z[0] - z[1]) % 10 != 0 and i * z[0] % 10 != 0:
	count += 1
	i += 1
print(count + 1)


(k, r) = map(int, input().split())
possible = []
for i in range(1, 11):
	if k * i % 10 == 0 or (k * i - r) % 10 == 0:
		possible.append(i)
print(min(possible))


x = [int(x) for x in input().split()]
(k, r) = (x[0], x[1])
i = 1
while True:
	if k * i % 10 == 0:
		a = i
		print(a)
		break
	elif k * i % 10 == r:
		b = i
		print(b)
		break
	i += 1


line = input()
arr = line.split()
price = int(arr[0])
r = int(arr[1])
shovel = 1
while shovel > 0:
	check = price * shovel
	if check % 10 == 0:
		break
	elif check % 10 == r:
		break
	else:
		shovel = shovel + 1
print(shovel)


l = list(map(int, input().split()))
if l[0] % 10 == 0:
	print(1)
	exit()
for i in range(1, 10):
	pp = l[0] * i
	if pp % 10 == l[1] or pp % 10 == 0:
		print(i)
		exit()


(k, r) = [int(n) for n in input().split()]
k %= 10
sum = k
n = 1
while sum not in {r, 0}:
	sum = (sum + k) % 10
	n += 1
print(n)


(k, r) = map(int, input().split())
e = [min(k * i % 10, (k * i - r) % 10) for i in range(1, 11)]
print(e.index(0) + 1)


(n, r) = map(int, input().split())
for i in range(1, 11):
	if i * n % 10 in [0, r]:
		break
print(i)


(a, b) = map(int, input().split(' '))
n = 1
k = 1
while True:
	n = k * a
	if n % 10 == b or n % 10 == 0:
		print(k)
		break
	k += 1


def findAmount(price, coin):
	shovels = 1
	while shovels != 999:
		if (price * shovels - coin) % 10 == 0:
			return shovels
		elif price * shovels % 10 == 0:
			return shovels
		shovels += 1
listOfInputs = input().split()
print(findAmount(int(listOfInputs[0]), int(listOfInputs[1])))


(k, r) = map(int, input().split())
c = 1
x = 2
z = k
while k % 10 != 0 and k % 10 != r:
	c += 1
	k = z * x
	x += 1
print(c)


import time
x = input().split(' ')
price = int(x[0])
r = int(x[1])
counter = 1
price = price % 10
bb = price + 0
while price != r:
	if price % 10 == 0:
		break
	price = price + bb
	if price > 10:
		price = price % 10
	counter = counter + 1
print(counter)


(k, r) = map(int, input().split())
if k == 10 or k == r:
	print(1)
else:
	br = False
	for n in range(1, 11):
		i = 0
		while n * k > 10 * i:
			if n * k % 10 == 0 or n * k == 10 * i + r:
				print(n)
				br = True
				break
			i += 1
		if br:
			break


(n, g) = map(int, input().split(' '))
s = n
f = n % 10
count = 1
while f != 0 and f != g:
	s += n
	f = s % 10
	count += 1
print(count)


def f(s, i, m):
	if (s * i - m) % 10 == 0:
		return False
	elif s * i % 10 == 0:
		return False
	else:
		return True

def main():
	(s, m) = map(int, input().split())
	i = 1
	while f(s, i, m):
		i += 1
	print(i)
	return 0
main()


import string
a = input()
a = a.split()
k = int(a[0])
r = int(a[1])
x = [0, r]
for i in range(1, 11):
	if k * i % 10 in x:
		print(i)
		break


emon = input().split()
x = int(emon[0])
y = int(emon[1])
a = 0
for i in range(1, 10):
	m = x * i
	if m % 10 == 0:
		print(i)
		a += 1
		break
	m = list(str(m))
	if int(m[-1]) == y:
		print(i)
		a += 1
		break
if a == 0:
	print('1')


def counter(k, r):
	number = 1
	while True:
		price = k * number
		if price % 10 == r or price % 10 == 0:
			return number
		else:
			number = number + 1
(k, r) = map(int, input().split())
print(counter(k, r))


(amt, d) = [int(x) for x in input().split()]
ans = 10
for i in range(1, 11):
	temp = amt * i
	if temp % 10 == 0 or temp % 10 - d == 0:
		ans = min(ans, i)
		break
print(ans)


[a, b] = map(int, input().split())
m = 1
while b != a * m % 10 != 0:
	m += 1
print(m)


n = input().split()
ans = 0
i = 0
while ans == 0:
	i += 1
	a = int(n[0]) * i
	if a % 10 == 0 or a % 10 == int(n[1]):
		ans = i
print(ans)


(x, y) = [int(i) for i in input().split(' ')]
n = 1
while x * n % 10 != y and x * n % 10 != 0:
	n += 1
print(n)


n = list(input().split(' '))
k = int(n[0])
r = int(n[1])
i = 1
while 1:
	if k * i % 10 == 0 or k * i % 10 == r:
		break
	i += 1
print(i)


(shovel_price, burle_value) = map(int, input().split())
count = 1
while True:
	new_shovel_price = shovel_price * count
	if new_shovel_price % 10 == 0 or (new_shovel_price - burle_value) % 10 == 0:
		break
	count += 1
print(count)


(x, y) = input().split()
x = int(x)
count = 0
sum = 1
while sum % 10 != 0:
	count += 1
	sum = count * x - int(y) if x * count % 10 != 0 else count * x
print(count)


(k, r) = input().split()
x = int(k[-1])
i = 1
while str(x * i)[-1] != r and str(x * i)[-1] != '0':
	i += 1
print(i)


(s, f) = map(int, input().split())
c = s
C = 1
while s % 10 != 0 and str(s)[-1] != str(f):
	s = s + c
	C += 1
print(C)


(k, r) = [int(x) for x in input().split()]
mde = []
for i in range(1, 10):
	if k * i % 10 == 0 or k * i % 10 == r:
		mde.append(i)
print(min(mde))


line = input().split()
k = int(line[0])
r = int(line[1])
for a in range(1, 11):
	if k * a % 10 == 0 or k * a % 10 == r:
		print(str(a))
		break


(n, r) = [int(x) for x in input().split()]
for i in range(1, 11):
	if (n * i - r) % 10 == 0 or n * i % 10 == 0:
		print(i)
		exit()


(price, coin) = list(map(int, input().split(' ')))
n_shovels = 1
total_price = price
while str(total_price)[-1] != str(coin) and total_price % 10 != 0:
	n_shovels += 1
	total_price += price
print(n_shovels)


nm = input().split()
n = int(nm[0])
m = int(nm[1])
for i in range(1, 9999999999999999999):
	if i * n % 10 == m or i * n % 10 == 0:
		print(i)
		break


(c, b) = map(int, input().split())
x = 1
while True:
	fat = c * x
	if fat % 10 == 0 or fat % 10 == b:
		print(x)
		break
	x += 1


(a, b) = input().split()
d = int(b)
for x in range(1, 10):
	c = x * int(a[-1])
	e = str(c)
	if int(e[-1]) == d or int(e[-1]) == 0:
		print(x)
		break


(K, R) = [int(x) for x in input().split()]
I = 1
while True:
	if I * int(K) % 10 == 0:
		print(I)
		break
	if (I * int(K) - int(R)) % 10 == 0:
		print(I)
		break
	else:
		I += 1


(a, b) = map(int, input().split())
lop = 0
a1 = a
while 5 != 1:
	lop += 1
	if a % 10 == b or a % 10 == 0:
		break
	if a % 10 != b:
		a = a + a1
print(lop)


(price, r) = map(int, input().split())
i = 1
while True:
	m = i * price
	if divmod(m - r, 10)[1] == 0 or divmod(m, 10)[1] == 0:
		print(i)
		exit()
	i += 1


import sys
paratmetrs = list(map(int, input().split()))
price = paratmetrs[0]
rest = paratmetrs[1]
status = True
count = 0
while status:
	count += 1
	order = price * count
	if order % 10 == 0 or (order - rest) % 10 == 0:
		status = False
print(count)


(q, w) = map(int, input().split())
i = 1
while i < 10:
	if (q * i % 10 == w) | (q * i % 10 == 0):
		break
	i += 1
print(i)


(k, r) = map(int, input().split())
m = k
lis = [int(x) for x in str(k)]
while lis[-1] != r and lis[-1] != 0:
	k += m
	lis = [int(x) for x in str(k)]
print(k // m)


(price, coin) = map(int, input().split(' '))
num = 1
while True:
	cost = price * num
	cost = str(cost)
	left = int(cost[-1])
	if left == coin or left == 0:
		break
	num += 1
print(num)


(pr, ch) = input().split(' ')
for x in range(1, 101):
	if (x * int(pr) - int(ch)) % 10 == 0:
		break
for y in range(1, 101):
	if y * int(pr) % 10 == 0:
		break
if x > y:
	print(y)
else:
	print(x)


(price, coin) = map(int, input().split())
count = 1
while price * count % 10 != 0 and price * count % 10 != coin:
	count += 1
print(count)


def solve(k, r):
	for i in range(1, 11):
		n = i * k
		if n % 10 == r or n % 10 == 0:
			return i

def main():
	(k, r) = list(map(int, input().split()))
	print(solve(k, r))
main()


m = input()
k = int(m.split()[0])
r = int(m.split()[1])
i = 1
while True:
	rem = divmod(k * i, 10)[1]
	if rem == r or rem == 0:
		break
	i += 1
print(i)


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


(price, coin) = map(int, input().strip().split())
for i in range(1, 11):
	if price * i % 10 in (0, coin):
		break
print(i)


(x, y) = map(int, input().split())
for i in range(1, 11):
	v = x * i
	if v % 10 == 0 or (v - y) % 10 == 0:
		s = i
		break
	else:
		s = 10
print(s)


(k, r) = input().split()
k = int(k)
r = int(r)
b = 1
m = k
while True:
	if k % 10 == 0:
		print(b)
		break
	if (k - r) % 10 == 0:
		print(b)
		break
	b += 1
	k = k + m


import sys
(k, r) = [int(i) for i in input().split()]
i = 1
while i < 10:
	if k * i % 10 == r or k * i % 10 == 0:
		print(str(i))
		sys.exit(0)
	i += 1
print(str(10))


num = list(map(int, input().split()))
price = num[0]
change = num[1]
count = 1
while price % 10 != change:
	final = price * count
	if final % 10 == change:
		break
	elif final % 10 == 0:
		break
	count += 1
print(count)


(num, r) = input().split()
num = int(num)
r = int(r)
n = num
i = 0
while n % 10 != r:
	if n % 10 == 0:
		break
	n = num * (i + 1)
	i = i + 1
if i == 0:
	i = 1
print(i)


a = list(map(int, input().split()))
c = 0
k = 0
while True:
	b = k * a[0]
	if b - a[1] > 0 and (b - a[1]) % 10 == 0:
		print(k)
		break
	elif a[1] % a[0] == 0 and a[1] != 0 and (k > a[1] // a[0]):
		print(a[1] // a[0])
		break
	elif k * a[0] % 10 == 0 and k != 0:
		print(k)
		break
	else:
		k += 1


(k, r) = map(int, input().split())
ct = 1
while 0 != k * ct % 10 != r:
	ct += 1
print(ct)


import math
from collections import Counter

def get(f):
	return map(f, input().split())

def divides(a, b):
	return a % b == 0

def main():
	(k, r) = get(int)
	acc = 0
	while True:
		if acc != 0 and divides(acc, k):
			print(math.floor(acc / k))
			return
		elif divides(acc + r, k):
			print(math.floor((acc + r) / k))
			return
		acc += 10
main()


(K, R) = (int(x) for x in input().split())
a = K % 10
cost = 0
val = 10
for i in range(1, 11):
	cost += a
	if cost % 10 in [0, R]:
		val = i
		break
print(val)


s = input()
l = s.split(' ')
k = int(l[0])
r = int(l[1])
count = 0
count1 = 0
for i in range(1, 11):
	s = str(i * k)
	if s[-1] == str(r):
		count = i
		print(count)
		break
	if i * k % 10 == 0:
		count1 = i
		print(count1)
		break


(cost, r) = [int(x) for x in input().split()]
for n in range(1, 10):
	if cost * n % 10 == r or cost * n % 10 == 0:
		print(n)
		break


def r(t=int):
	return list(map(t, input().split()))

def ri(t=int):
	return t(input())

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
(k, d) = r()
ans = 1
while k * ans % 10 != d and k * ans % 10:
	ans += 1
print(ans)


(k, r) = map(int, input().rstrip().split())
for i in range(1, 10):
	if k * i % 10 == 0 or (k * i - r) % 10 == 0:
		c = i
		print(i)
		break


(p, k) = map(int, input().split())
if p % 10 == k or p % 10 == 0:
	print(1)
else:
	for i in range(2, 10):
		if p * i % 10 == k or p * i % 10 == 0:
			print(i)
			break


(k, r) = list(map(int, input().split()))
r = str(r)
i = 1
while 1:
	s = str(k * i)
	if s[-1] == '0':
		print(i)
		break
	elif s[-1] == r:
		print(i)
		break
	else:
		i = i + 1


def main():
	(k, r) = map(str, input().split())
	temp = k[-1]
	for i in range(1, 10):
		temp2 = i * int(temp)
		temp2 = str(temp2)
		if temp2[-1] == '0' or temp2[-1] == r:
			print(i)
			return
	print(10)
main()


(k, r) = input().split()
k = int(k)
for i in range(1, 11):
	k = int(k)
	k *= i
	s = str(k)
	if s[len(s) - 1] == r or k % 10 == 0:
		break
	k /= i
print(i)


(k, r) = map(int, input().split())
i = 1
while True:
	if k * i % 10 in (0, r):
		print(i)
		break
	i += 1


inp = input().split(' ')
(k, r) = (int(inp[0]), int(inp[1]))
i = 1
f = False
while f != True:
	if (k * i - r) % 10 == 0 or k * i % 10 == 0:
		f = True
	else:
		i += 1
print(i)


c = list(map(int, input().split()))
a = int(c[0])
b = int(c[1])
g = []

def ragham(x):
	x = str(x)
	y = int(x[-1])
	return y
if a < 10 and b >= a:
	if b % a == 0:
		print(b // a)
	elif a == 5:
		print(2)
	elif ragham(3 * a) == b or ragham(3 * a) == 0:
		print(3)
	elif ragham(4 * a) == b or ragham(4 * a) == 0:
		print(4)
	elif ragham(5 * a) == b or ragham(5 * a) == 0:
		print(5)
	elif ragham(6 * a) == b or ragham(6 * a) == 0:
		print(6)
	elif ragham(7 * a) == b or ragham(7 * a) == 0:
		print(7)
	elif ragham(8 * a) == b or ragham(8 * a) == 0:
		print(8)
	elif ragham(9 * a) == b or ragham(9 * a) == 0:
		print(9)
elif a < 10 and a < b:
	print(0)
elif ragham(a) == b:
	print(1)
elif ragham(a) == 0:
	print(1)
elif ragham(a) == 5:
	print(2)
elif ragham(2 * a) == b or ragham(2 * a) == 0:
	print(2)
elif ragham(3 * a) == b or ragham(3 * a) == 0:
	print(3)
elif ragham(4 * a) == b or ragham(4 * a) == 0:
	print(4)
elif ragham(5 * a) == b or ragham(5 * a) == 0:
	print(5)
elif ragham(6 * a) == b or ragham(6 * a) == 0:
	print(6)
elif ragham(7 * a) == b or ragham(7 * a) == 0:
	print(7)
elif ragham(8 * a) == b or ragham(8 * a) == 0:
	print(8)
elif ragham(9 * a) == b or ragham(9 * a) == 0:
	print(9)


(k, r) = map(int, input().split())
i = 1
while 1:
	a = k * i
	a = str(a)
	r = str(r)
	if a[-1] == r or a[-1] == '0':
		break
	i += 1
print(i)


import sys
import os.path
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')
(n, r) = map(int, input().split())
ans = n % 10
for i in range(1, 10):
	if i * ans % 10 == 0 or i * ans % 10 == r:
		print(i)
		break


(k, r) = map(int, input().split())

def find(k, i, r):
	x = k * i % 10
	if x == r or x == 0:
		print(i)
		return 0
	else:
		return i + 1
i = 1
while i > 0:
	i = find(k, i, r)


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


(k, r) = map(int, input().split())
i = 0
while i >= 0:
	x = 10 * i
	y = x + r
	if 10 * i % k == 0 and i != 0:
		print(10 * i // k)
		break
	if y % k == 0:
		a = y // k
		print(a)
		break
	i = i + 1


(k, r) = [int(x) for x in input().split()]
n = 1
sum = k
while sum % 10 != r and sum % 10 != 0:
	n += 1
	sum += k
print(n)


l = list(map(int, input().split()))
a = l[0]
c = l[1]
for i in range(1, 10000000000000):
	p = a * i
	if p % 10 == 0 or p % 10 == c:
		break
print(i)


(p, u) = [int(x) for x in input().split()]
n = 1
t = p
while t % 10 != u and t % 10 != 0:
	n += 1
	t += p
print(n)


(k, r) = [int(x) for x in input().split()]
tmp = k % 10
num_shovels = 1
while 1:
	if tmp == r or tmp == 0:
		break
	num_shovels += 1
	if num_shovels >= 10:
		break
	tmp = k * num_shovels % 10
print(num_shovels)


__author__ = 'Alexander'
import sys
(k, r) = map(int, sys.stdin.readline().split())
ost = k % 10
for i in range(1, 10):
	if ost * i % 10 == r or ost * i % 10 == 0:
		sys.stdout.write(str(i))
		break


from sys import stdin, stdout
from math import gcd, sqrt, floor, ceil

def list_inp(x):
	return list(map(x, input().split()))

def map_inp(x):
	return map(x, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
(a, b) = map_inp(int)
for i in range(1, 10):
	if i * a % 10 == 0 or a * i % 10 == b:
		print(i)
		break


a = input().split(' ')
k = int(a[0])
r = int(a[1])
cnt = 1
pro = 1
while 1:
	if k * pro % 10 == r or k * pro % 10 == 0:
		break
	else:
		cnt = cnt + 1
	pro = pro + 1
print(cnt)


from sys import stdin, stdout
(k, r) = map(int, stdin.readline().rstrip().split())
x = 1
while 1:
	if x == 10 or (k * x - r) % 10 == 0 or k * x % 10 == 0:
		break
	else:
		x += 1
print(x)


(k, r) = [int(k) for k in input().split()]
sur = k % 10
if sur == 5:
	if r == 5:
		print('1')
	if r != 5:
		print('2')
	exit()
if sur == 0:
	print('1')
	exit()
for i in range(1, 10):
	tmp = i * sur
	if tmp % 10 == r:
		print(i)
		exit()
for i in range(5, 15, 5):
	if i * sur % 10 == 0:
		print(i)
		exit()


(k, r) = input().split()
k = int(k[-1])
z = 1
r = int(r)
if k == 0:
	z = 1
else:
	n = k
	while r != k and k != 0:
		z = z + 1
		k = k + n
		k = int(str(k)[-1])
print(z)


(k, r) = [int(i) for i in input().split()]
k %= 10
k1 = k
ctr = 1
while k != r and k != 0:
	k += k1
	k %= 10
	ctr += 1
print(ctr)


(k, r) = map(int, input().strip().split())
current = k
while current % 10 != r and current % 10 != 0:
	current += k
print(current // k)


(a, b) = map(int, input().split())
c = a
d = str(b)
x = 1
while str(a)[-1] != '0' and str(a)[-1] != d:
	a += c
	x += 1
print(x)


(shovel, coin) = input().split()
shovel = int(shovel)
coin = int(coin)
if shovel % 10 == 0:
	print('1')
else:
	i = 1
	while i > 0:
		if (i * shovel - coin) % 10 == 0:
			print(i)
			break
		elif i * shovel % 10 == 0:
			print(i)
			break
		i += 1


(n, k) = list(map(int, input().split()))
temp = n
(Bool, count) = (True, 1)
while Bool:
	x = n % 10
	if x == k or x == 0:
		print(count)
		Bool = False
	else:
		count += 1
		n += temp


(n, m) = map(int, input().split())
for i in range(1, 10, 1):
	so_tien = n * i
	if so_tien % 10 == 0:
		print(i)
		quit()
	elif so_tien % 10 == m:
		print(i)
		quit()


def shovelamount():
	(k, r) = map(int, input().split())
	if k % 10 == 0:
		return 1
	elif k % 10 > 0:
		l_digit = k % 10
		if l_digit == 5 and r != 5:
			return 2
		else:
			for i in range(1, 11, 1):
				value = k * i
				vl_digit = value % 10
				if value % 10 == 0 or vl_digit == r:
					return i
print(shovelamount())


def read_array():
	x = []
	x1 = []
	x = input()
	x = x.split(' ')
	for v in x:
		x1.append(int(v))
	return x1
x = read_array()
(k, r) = (x[0], x[1])
m = 0
while True:
	m += 1
	if m * k % 10 == r or m * k % 10 == 0:
		print(m)
		break


(k, r) = map(int, input().split())
for a in range(1, 11):
	price = k * a % 10
	if price == r or price == 0:
		print(a)
		break


(price, change) = map(int, input().split())
i = 1
while i * price % 10 != 0 and i * price % 10 != change:
	i += 1
print(i)


(price, r) = [int(x) for x in input().split()]
shovels = 1
while (price * shovels - r) % 10 != 0 and shovels * price % 10 != 0:
	shovels += 1
print(shovels)


n = list(map(int, input().split()))
a = str(n[0])
i = 1
while a[len(a) - 1] != str(n[1]) and a[len(a) - 1] != '0':
	i += 1
	y = n[0] * i
	a = str(y)
print(i)


(st, rub_1_9) = map(int, input().split())
count = 1
while count * st % 10 != rub_1_9 and count * st % 10 != 0:
	count += 1
else:
	print(count)


import math

def BuubleSort(a, b):
	i = 1
	cnt = 0
	x = a
	while True:
		if x % 10 == 0 or x % 10 == b:
			break
		cnt += 1
		i += 1
		x = a * i
	return i

def main():
	(a, b) = map(int, input().split())
	ans = BuubleSort(a, b)
	print(ans)
main()


(price, coin) = map(int, input().split())
quantity = 1
temp = price
while True:
	if price == coin or price % 10 == 0 or (price - coin) % 10 == 0:
		break
	else:
		quantity += 1
		price += temp
print(quantity)


(k, r) = input().split()
k = int(k)
r = int(r)
numberOfShovel = 0
for numberOfShovel in range(1, 11):
	if numberOfShovel * k % 10 == 0 or (numberOfShovel * k - r) % 10 == 0:
		break
print(numberOfShovel)


data = list(map(int, input().split()))
number = 1
while data[0] * number % 10 != data[1] and data[0] * number % 10 != 0:
	number += 1
print(number)


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


(a, b) = map(int, input().split())
a = a % 10
d = a
c = 1
for i in range(9):
	if not a or a == b:
		print(c)
		break
	else:
		a = (a + d) % 10
		c += 1
if c == 10:
	print(10)


import sys
a = list(map(int, input().split()))
n = a[0]
c = a[1]
sum = 1
while True:
	if n * sum % 10 == c or n * sum % 10 == 0:
		print(sum)
		sys.exit()
	else:
		sum = sum + 1


(a, b) = map(int, input().split())
x = 1
while True:
	if x * a % 10 == 0 or x * a % 10 == b:
		break
	x += 1
print(x)


I = lambda : list(map(int, input().split()))
(k, r) = I()
ans = 1
while ans * k % 10 != r and ans * k % 10 != 0:
	ans += 1
print(ans)


(k, r) = map(int, input().split())
y = []
for i in range(1, 10):
	x = str(i * k)
	y = int(x[-1])
	if y == r or y == 0:
		print(i)
		break


n = 10
(p, r) = map(int, input().split())
if (r / p).is_integer():
	print(r // p)
elif r != p:
	while n % p != 0 and (n + r) % p != 0:
		n += 10
	if (n / p).is_integer():
		print(n // p)
	else:
		print((n + r) // p)


l = list(map(int, input().split()))
(p, q) = (l[0], l[1])
sum = p
i = 1
while i <= 10:
	if sum % 10 == q or sum % 10 == 0:
		break
	sum += p
	i += 1
print(i)


a = [int(s) for s in input().split()]
(k, r, t, kol) = (a[0], a[1], 0, 0)
while True:
	kol += 1
	t += k
	if t % 10 == 0 or (t - r) % 10 == 0:
		break
print(kol)


(p, m) = map(int, input().split())
c = 1
while p * c % 10 not in [0, m]:
	c += 1
print(c)


def ans(a, b):
	i = 1
	while i * a % 10 != b and i * a % 10 != 0:
		i += 1
	return i
(k, r) = map(int, input().split())
print(ans(k, r))


inp = input().split(' ')
k = int(inp[0])
r = int(inp[1])
i = 1
while True:
	s = k * i % 10
	if s == 0 or s == r:
		print(i)
		break
	else:
		i += 1


list1 = input().split()
list2 = [int(i) for i in list1]
k = list2[0] % 10
r = list2[1]
n = 1
if k == r:
	print(1)
elif k % 10 == 0:
	print(1)
elif k % 5 == 0:
	print(2)
else:
	while k * n % 10 != r and k * n % 10 != 0:
		n += 1
	print(n)


(a, b) = map(int, input().split())
c = a % 10
i = 1
if c == b:
	print(1)
elif c == 0:
	print(1)
elif c == 5:
	print(2)
else:
	d = a
	while 0 != d % 10 != b:
		d += a
		i += 1
	print(i)


k = input().split()
(k, r) = (int(k[0]), int(k[1]))
count = 1
t = k
while k % 10 != r and k % 10 != 0:
	count += 1
	k += t
print(count)


(k, r) = map(int, input().split())
sm = 0
for i in range(1, 11):
	s = k * i
	if s % 10 == 0 or s % 10 == r:
		sm += 1
		break
	else:
		sm += 1
print(sm)


a = input()
b = a.split(' ')
b[0] = int(b[0])
b[1] = int(b[1])
x = 0
m = 1
while m == 1:
	x = x + 1
	if str(b[0] * x)[-1] == str(b[1])[0] or str(b[0] * x)[-1] == '0':
		m = m + 1
print(x)


(n, m) = map(int, input().split())
i = 1
q = n
while n % 10 != m and n % 10 != 0:
	n += q
	i += 1
print(i)


(k, r) = map(int, input().split())
for n in range(1, 100):
	if k * n % 10 in (0, r):
		print(n)
		break


(k, r) = map(int, input().split())
for v in range(1, 11):
	if v * k % 10 == r or v * k % 10 == 0:
		print(v)
		break
else:
	print(10)


(s, r) = input().split()
k = int(s)
r = int(r)
i = 1
while True:
	if int(s[-1]) == 0 or int(s[-1]) == r:
		print(i)
		break
	else:
		i += 1
		p = k * i
		s = str(p)


inputstring = input().split()
k = int(inputstring[0])
r = int(inputstring[1])
rate = 1
while True:
	if k * rate % 10 == r or not k * rate % 10:
		print(rate)
		break
	else:
		rate += 1


a = input()
b = a.split()
k = 1
while k < 11:
	if k * int(b[0]) % 10 == 0 or k * int(b[0]) % 10 == int(b[1]):
		break
	k += 1
print(k)


numbers = [int(i) for i in input().split()]
price = numbers[0]
extra = numbers[1]
for x in range(1, 11):
	if price * x % 10 == 0:
		print(x)
		break
	elif (price * x - extra) % 10 == 0:
		print(x)
		break


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


ff = input()
ff = ff.split()
shovel = int(ff[0])
r = int(ff[1])
k = 1
std = shovel
while (shovel % 10 != 0) & (shovel % 10 != r):
	k += 1
	shovel = std * k
print(k)


from math import ceil, log, floor, sqrt
import math

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def get_string(n):
	s = 'codeforces'
	l = []
	res = ''
	flag = True
	if n == 1:
		return s
	for i in range(10):
		l.append(1)
	m = 1
	while flag:
		for i in range(10):
			m = m * (l[i] + 1) // l[i]
			l[i] += 1
			if m >= n:
				flag = False
				break
	for i in range(10):
		for j in range(l[i]):
			res += s[i]
	return res

def nc2(n):
	return n * (n + 1) / 2

def get_grain_count(n, l, m):
	print(l, n - nc2(l) - (m + l + 1))
	return n - nc2(l) - (m + l + 1)

def count_days(n, m):
	if n == 1:
		return 1
	value = 2 * (n - m - 1)
	l = ceil((-3 + sqrt(9 + 4 * value)) / 2)
	while get_grain_count(n, l, m) > 0:
		l += 1
	return m + l + 1

def get_count(k, r):
	for i in range(1, 10):
		if (k * i - r) % 10 == 0 or k * i % 10 == 0:
			return i
	return 10
t = 1
while t:
	t = t - 1
	(k, r) = map(int, input().split())
	print(get_count(k, r))


from sys import stdin
string = stdin.readline().strip().split(' ')
n = int(string[0])
r = int(string[1])

def solution(k, r):
	count = 1
	while (k * count - r) % 10 != 0 and k * count % 10 != 0:
		count += 1
	return count
print(solution(n, r))


(k, r) = map(int, input().split())
if k % 10 == r:
	print(1)
else:
	prod = k
	shovels = 0
	i = 1
	while True:
		if prod % 10 == 0 or prod % 10 == r:
			shovels += 1
			break
		shovels += 1
		i += 1
		prod = k
		prod = k * i
	print(shovels)


from sys import stdin, stdout
(p, n) = map(int, stdin.readline().rstrip().split(' '))
a = 10
for i in range(1, 10, 1):
	temp0 = p * i % 10
	if temp0 == 0 or temp0 == n:
		a = i
		break
stdout.write(str(a) + '\n')


inp = [int(x) for x in input().split()]
n = inp[0] % 10
k = inp[1]
b = 0
r = n
for _ in range(10):
	b += 1
	if r == k or r == 0:
		print(b)
		break
	r = (r + n) % 10


(k, r) = map(int, input().split())
l = k
ch = 1
if (k - r) % 10 == 0:
	print('1')
while (k - r) % 10 != 0:
	if k % 10 == 0:
		print(ch)
		break
	ch = ch + 1
	k = l * ch
	if (k - r) % 10 == 0:
		print(ch)
	continue


(a, b) = [int(i) for i in input().split()]
n = 1
k = a * n
if int(str(k)[-1]) == 5 and b != 5:
	print(2)
elif int(str(k)[-1]) == 5 and b == 5:
	print(1)
elif int(str(k)[-1]) == 0:
	print(1)
else:
	while int(str(k)[-1]) != b:
		n += 1
		k = a * n
		if int(str(k)[-1]) == 0:
			break
	print(n)


(a, b) = map(int, input().split())
i = 1
while True:
	if a * i % 10 == b or a * i % 10 == 0:
		print(i)
		quit()
	i += 1


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


(K, R) = map(int, input().split())
cnt = 1
while True:
	if cnt * K % 10 == 0 or cnt * K % 10 == R:
		break
	cnt += 1
print(cnt)


(m, n) = [int(i) for i in input().split()]
a = str(m)
i = int(a[-1])
s = i
c = 1
while s != n and c < 10 and (s != 0):
	s = int(str(i + s)[-1])
	c += 1
print(c)


def main():
	(shovel, coin) = [int(s) for s in input().split()]
	s = shovel % 10
	for i in range(1, 11):
		if s * i % 10 in (coin, 0):
			print(i)
			return
main()


(k, r) = [int(x) for x in input().split()]
for m in range(1, 11):
	if m * k % 10 == r or m * k % 10 == 0:
		break
	else:
		m += 1
print(m)


(n, h) = input().split()
h = int(h)
temp = list(map(int, n))
count = 0
for i in range(1, 10):
	temp2 = list(map(int, str(temp[-1] * i)))
	if temp2[-1] == h or temp2[-1] == 0:
		count = i
		break
print(count)


nums = input()
nums = nums.split(' ')
k = int(nums[0])
r = int(nums[1])
n = 1
bur = 10
while k * n % bur - r != 0 and k * n % bur != 0:
	n += 1
print(n)


import sys
import math
n = list(input().split())
n = [int(i) for i in n]
k = n[0]
r = n[1]
cnt = 1
while 1:
	if k * cnt / 10 == k * cnt // 10:
		print(cnt)
		sys.exit()
	elif (k * cnt - r) / 10 == (k * cnt - r) // 10:
		print(cnt)
		sys.exit()
	cnt += 1


(k, r) = map(int, input().split())
a = 10
a1 = 1
t = 0
d = 0
t = k % 10
if t % 2 == 0:
	a = a / 2
if t % 5 == 0:
	a = a / 5
d = k - r
while d % 10 != 0 and a1 < 11:
	d += k
	a1 += 1
a = int(a)
print(min(a, a1))


(k, r) = [int(__) for __ in input().strip().split()]
ans = 1
while True:
	cal = ans * k
	if cal % 10 == 0 or cal % 10 == r:
		break
	else:
		ans += 1
print(ans)


(a, b) = map(int, input().split())
e = 1
n = 0
z = a
while n == 0:
	if (a - b) % 10 == 0 or a % 10 == 0:
		break
	else:
		a += z
		e += 1
print(e)


I = input
d = [int(i) for i in I().split(' ')]
i = 1
while True:
	if i * d[0] % 10 == d[1] or i * d[0] % 10 == 0:
		print(i)
		break
	i += 1


def main():
	(shovel, coin) = map(int, input().split())
	x = 0
	while True:
		x += 1
		if shovel * x % 10 == 0:
			break
		elif shovel * x % 10 == coin:
			break
	print(x)
main()


(price, extra) = map(int, input().split())
count = 0
total = 0
while True:
	total = total + price
	count += 1
	if total % 10 == 0 or total % 10 == extra:
		print(count)
		break


(k, n) = map(int, input().split())
z = 1
t = 1
l = k
while k % 10 != 0:
	t = t + 1
	k = l
	k = k * t
k = l
while k % 10 != n:
	z = z + 1
	k = l
	k = k * z
	if z == 10:
		break
if z > t:
	print(t)
else:
	print(z)


(n, m) = map(int, input().split())
t = 0
for i in range(1, 10):
	if n * i % 10 == m or n * i % 10 == 0:
		t = i
		break
if n % 5 == 0 and t == 0:
	if n % 10 == 0:
		print(1)
	elif n % 5 == 0:
		print(2)
else:
	print(t)


(k, r) = map(int, input().split())
res = 1
counter = 0
rem = k % 10
num = k - rem
i = 2
if k % 10 == 0:
	print(res)
else:
	while num % 10 != 0 or rem / r != 1:
		x = k * i
		rem = x % 10
		num = x - rem
		res = res + 1
		if rem == 0:
			break
		i = i + 1
	print(res)


(k, r) = input().split()
(k, r) = (int(k), int(r))
ans = 1
while 1:
	if ans * k % 10 == r or ans * k % 10 == 0:
		print(ans)
		break
	ans += 1


def main():
	try:
		while True:
			(k, r) = map(int, input().split())
			for i in range(1, 11):
				if i * k % 10 in (0, r):
					print(i)
					break
	except EOFError:
		pass
main()


(a, b) = input().strip().split(' ')
(a, b) = [int(a), int(b)]
m = 0
l = []
for i in range(1, 10):
	if a * i % 10 - b == 0:
		l.append(i)
	elif a * i % 10 == 0:
		l.append(i)
print(min(l))


ini = input()
gla = ini.split()
par = []
ine = 1
us = int(gla[0])
while us * ine % 10 != int(gla[1]) and us * ine % 10 != 0:
	par.append(ine)
	ine += 1
print(len(par) + 1)


(k1, r1) = input().split()
k = int(k1)
r = int(r1)
g = 1
p = 10 - k % 10
while True:
	h = k * g
	l = str(h)
	if h % 10 == 0 or l.endswith(r1):
		print(g)
		exit()
	g = g + 1


(cost, d) = map(int, input().split())
first = cost
shovel = 1
while True:
	if cost % 10 == 0 or (cost - d) % 10 == 0:
		break
	cost += first
	shovel += 1
print(shovel)


inp = input().split()
k = int(inp[0])
r = int(inp[1])
kmin = float('inf')
for i in range(1, 11):
	if k * i % 10 == 0:
		kmin = i
		break
alphamin = float('inf')
for i in range(1, 11):
	if (k * i - r) % 10 == 0:
		alphamin = i
		break
print(min(kmin, alphamin))


(k, r) = [int(var) for var in input().split()]
initial_value = k
count = 0
for i in range(1, 11):
	if k * i % 10 == 0 or k * i % 10 == r:
		print(i)
		break


(p, c) = map(int, input().split(' '))
z = 0
i = 1
while i <= 10:
	p1 = p
	p1 *= i
	i += 1
	if p1 % 10 == 0 or p1 % 10 == c:
		break
print(i - 1)


money = [int(n) for n in input().split()]
i = 1
while money[0] * i % 10 != 0 and money[0] * i % 10 != money[1]:
	i = i + 1
print(i)


(k, r) = [int(x) for x in input().split()]
res = 1
ost = k
while True:
	ost = res * k % 10
	if ost == 0 or ost == r:
		break
	res += 1
print(res)


(k, r) = [int(s) for s in input().split(' ')]
c = 1
p = c * k
while not p % 10 in [0, r]:
	c += 1
	p = c * k
print(c)


(price, r) = list(map(int, input().split()))
i = 1
done = False
while not done:
	ans = price * i
	if ans % 10 == r or ans % 10 == 0:
		done = True
	else:
		i += 1
print(i)


(k, r) = map(int, input().split())
a = 1
while True:
	if a * k % 10 == 0:
		print(a)
		break
	elif (a * k - r) % 10 == 0:
		print(a)
		break
	else:
		a += 1


(b, r) = map(int, input().split())
k_b = b
count = 1
while True:
	if (b - r) % 10 == 0 or b % 10 == 0:
		print(count)
		break
	else:
		b += k_b
		count += 1


inp = list(map(int, input().split(' ')))
echcst = inp[0]
coin = inp[1]
for i in range(1, 11):
	if i * echcst % 10 == 0:
		print(i)
		break
	elif (i * echcst - coin) % 10 == 0:
		print(i)
		break


def buy(k, r):
	shovels = 0
	price = k
	while True:
		shovels += 1
		if price % 10 - r == 0 or price % 10 == 0:
			return shovels
		price = price + k
(k, r) = map(int, input().split())
shovel = buy(k, r)
print(shovel)


def solve():
	(k, r) = map(int, input().split())
	shv = 1
	while True:
		if shv * k % 10 == 0 or (shv * k - r) % 10 == 0:
			return shv
		shv += 1
print(solve())


(p, k) = list(map(int, input().strip().split()))
for j in range(1, 100):
	if p * j % 10 == k or p * j % 10 == 0:
		print(j)
		break


(k, r) = map(int, input().split())
cnt = 1
while 0 != cnt * k % 10 != r:
	cnt += 1
print(cnt)


n = input()
l = map(int, n.split())
lst = list(l)
k = lst[0]
r = lst[1]
i = 1
while True:
	v = i * k
	last = v % 10
	if last == 0 or last == r:
		break
	i += 1
print(i)


(n, k) = map(int, input().split())
e = 10
for i in range(10, 0, -1):
	r = i * n
	if r % 10 == 0 or (r - k) % 10 == 0:
		e = i
print(e)


(n, r) = map(int, input().split())
for i in range(1, 11):
	if n * i % 10 == 0 or n * i % 10 == r:
		print(i)
		return


(a, b) = map(int, input().split())
c = int(str(a)[-1])
for i in range(1, 10):
	d = c * i
	if d % 10 == 0 or str(d)[-1] == str(b)[-1]:
		print(i)
		quit()


inpt = input()
(k, r) = [int(i) for i in inpt.split(' ')]
res = 1
while True:
	price = res * k
	if price % 10 == 0 or price % 10 == r:
		break
	res += 1
print(res)


(p, c) = map(int, input().split())
count = 0
x = 0
while (x - c) % 10 != 0:
	x += p
	count += 1
	if x % 10 == 0:
		break
print(count)


(price, coin) = map(int, input().split())
price = price % 10
count = 10
for _ in range(1, 11):
	if (price * _ - coin) % 10 == 0 or price * _ % 10 == 0:
		count = _
		break
print(count)


(price, money) = list(map(int, input().split()))
for quality in range(1, 11):
	if (price * quality - money) % 10 == 0 or price * quality % 10 == 0:
		print(quality)
		break


from sys import stdin

def get_user_input():
	return list(map(int, stdin.readline().rstrip().split()))
input_list = get_user_input()
(k, r) = (input_list[0], input_list[1])
i = 1
while True:
	res = i * k
	if res % 10 == 0 or res % 10 == r:
		break
	i += 1
print(i)


(price, change) = [int(a) for a in input().split()]
counter = 1
while True:
	if counter * price % 10 == 0:
		break
	elif counter * price % 10 - change == 0:
		break
	else:
		counter += 1
print(counter)


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


ch = input()
l = ch.split()
k = int(l[0])
r = int(l[1])
i = 1
p = k
while p % 10 != 0 and p % 10 != r:
	i = i + 1
	p = k * i
print(i)


def func(n, r):
	i = 1
	while True:
		if n * i % 10 == 0 or n * i % 10 == r:
			return i
		i += 1
(n, r) = list(map(int, input().split()))
print(func(n, r))


(a, b) = map(int, input().split())
numbr_a = a
numbr_b = b
while True:
	if a % 10 == b or a % 10 == 0:
		break
	a = a + numbr_a
if a % 10 == b:
	print(int(a / numbr_a))
elif a % 10 == 0:
	print(int(a / numbr_a))


def kol_lop(k, r):
	kol = 1
	while k * kol % 10 - r != 0 and k * kol % 10 != 0:
		kol += 1
	return kol
(k, r) = map(int, input().split())
print(kol_lop(k, r))


l = list(input().split())
n = int(l[0])
k = int(l[1])
result = 0
for i in range(1, 10):
	if n * i % 10 == k or n * i % 10 == 0:
		result = i
		break
if result == 0:
	result = 10
print(result)


(n, m) = map(int, input().split())
p = []
for i in range(1, 11):
	if i * n % 10 == 0:
		p.append(i)
for j in range(1, 11):
	if (j * n - m) % 10 == 0:
		p.append(j)
print(min(p))


(k, r) = input().split()
k = int(k)
i = 1
while True:
	if str(k * i)[-1] == r or str(k * i)[-1] == '0':
		break
	i += 1
print(i)


(k, r) = [int(x) for x in input().split()]
c = 1
rr = k
while True:
	if (rr - r) % 10 == 0:
		break
	if rr % 10 == 0:
		break
	rr += k
	c += 1
print(c)


(k, r) = list(map(int, input().split()))
n = 0
d = 'x'
while d != '0' and d != str(r):
	n += 1
	p = k * n
	d = str(p)[-1]
print(n)


(n, m) = map(int, input().split())
flag = True
i = 1
while flag:
	s = str(int(n * i))
	if s[-1] == str(m) or s[-1] == '0':
		print(i)
		flag = False
		break
	else:
		i += 1


lst = list(map(int, input().rstrip().split()))
x = lst[0]
y = lst[1]
a = 1
for i in range(1, 10):
	a = x * i
	if a % 10 == y or a % 10 == 0:
		b = i
		break
print(b)


(a, b) = list(map(int, input().split()))
for i in range(0, 100000):
	if (10 * i + b) % a == 0:
		print((10 * i + b) // a)
		break
	if i > 0 and 10 * i % a == 0:
		print(10 * i // a)
		break


(k, r) = map(int, input().strip().split())
increment = k
num = 0
while 1:
	if k % 10 == 0:
		num = int(k / increment)
		break
	elif k % 10 == r:
		num = num + 1
		break
	elif k % 10 != r:
		k = k + increment
		num = num + 1
print(num)


from sys import stdin
(k, r) = map(int, stdin.readline().split())
n = k
res = 1
while True is True:
	if n % 10 == 0 or n % 10 == r:
		print(res)
		break
	else:
		n += k
		res += 1


xx = input()
yy = [int(n) for n in xx.split()]
x = yy[0]
y = yy[1]
z = [int(n) for n in str(x)]
l = 1
if z[len(z) - 1] != y:
	for k in range(2, 10):
		if int(z[len(z) - 1] * k % 10) == y:
			l = k
			break
		else:
			l = 0
	if l == 0:
		n = 1
		while x * n % 10 != 0:
			n += 1
		l = n
print(l)


(k, r) = map(int, input().split())
ultimo_digito = k % 10
pas = 1
i = 2
while True:
	if ultimo_digito == 0 or ultimo_digito == r:
		break
	numero = k * i
	pas += 1
	ultimo_digito = numero % 10
	i += 1
print(pas)


(m, n) = map(int, input().rstrip().split())
(c, i) = (True, 1)
while c:
	if m * i % 10 == 0 or m * i % 10 == n:
		print(i)
		c = False
		break
	i += 1


(x, y) = input().split(' ')
(price, coin) = (int(x), int(y))
i = 1
while True:
	if i * price % 10 == 0 or i * price % 10 == coin:
		print(i)
		break
	i += 1


def main():
	(k, r) = list(map(int, input().split()))
	key = [0]
	key.append(r)
	jump = 10 - k % 10
	output = 0
	initial = k % 10
	while True:
		if initial in key:
			break
		initial -= jump
		output += 1
		if initial < 0:
			initial += 10
	print(output + 1)
main()


(x, y) = map(int, input('').split())
s = 1
while True:
	if x * s % 10 == 0 or x * s % 10 == y:
		print(s)
		break
	else:
		s += 1


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

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

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans
(n, k) = map(int, input().split())
a = 0
r = n % 10
if r == 0 or (n - k) % 10 == 0:
	a = 1
elif n % 5 == 0 and r != 0:
	a = 2
else:
	for i in range(1, 10):
		if r * i % 10 == k or r * i % 10 == 0:
			a = i
			break
	if a == 0:
		a = k
print(a)


import sys
(a, b) = input().split()
i = 1
while True:
	if int(a) * i % 10 == 0:
		print(i)
		break
	elif int(a) * i % 10 == int(b):
		print(i)
		break
	else:
		i = i + 1


(a, b) = map(int, input().split())
z = list(str(a))
i = 1
while int(z[-1]) != b:
	if int(z[-1]) == 0:
		break
	i += 1
	x = a * i
	z = list(str(x))
print(i)


(k, r) = input().split()
k = int(k)
i = 0
while True:
	i += 1
	ans = str(i * k)
	if ans[-1] == r or int(ans) % 10 == 0:
		print(i)
		break
	else:
		continue


def Buy_a_Shovel(k, r):
	i = 1
	for i in range(1, 20000):
		if i * k % 10 == 0 or (i * k - r) % 10 == 0:
			break
	return i
(k, r) = map(int, input().split())
print(Buy_a_Shovel(k, r))


(p, s) = tuple(map(int, input().split()))
for i in range(1, 10):
	if i * p % 10 == 0 or i * p % 10 == s:
		exit(print(i))
print(10)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(n, k) = sp()
for i in range(1, 100001):
	if (n * i - k) % 10 == 0 or n * i % 10 == 0:
		out(i)
		exit()


import sys
n = []
for apa in sys.stdin:
	n.append(apa)
	if apa == '\n':
		break
string = ' '.join(n).replace('\n', '')
lst = string.split()
x = int(lst[0])
y = lst[1]
for i in range(1, 10):
	ans = x * i
	ans = str(ans)
	if ans[-1] == y:
		print(i)
		break
	elif ans[-1] == '0':
		print(i)
		break


nk = tuple(map(int, input().split()))
sh = 1
while sh * nk[0] % 10 != 0 and (sh * nk[0] - nk[1]) % 10 != 0:
	sh += 1
print(sh)


(p, c) = map(int, input().split())
counter = 1
mul = 2
if p % 10 == 0:
	print(counter)
while p % 10 != 0:
	if p % 10 == c:
		print(counter)
		break
	else:
		incr = mul * p
		counter += 1
		mul += 1
		if incr % 10 == 0 or incr % 10 == c:
			print(counter)
			break


(a, b) = map(int, input().split())
count = 1
n = a
if (a - b) % 10 != 0 or a % 10 != 0:
	while (a - b) % 10 != 0 and a % 10 != 0:
		count += 1
		a = a + n
	print(count)
elif (a - b) % 10 == 0 or a % 10 == 0:
	print(1)


(k, r) = list(map(int, input().split()))
res = 1
temp = k
while temp % 10 != 0 and temp % 10 != r:
	res += 1
	temp = res * k
print(res)


(k, r) = map(int, input().split())
count = 1
m = k
flag = 0
while flag != 1:
	k = str(k)
	j = k[-1]
	if j == '0' or j == str(r):
		print(count)
		flag = 1
	else:
		count = count + 1
		k = m * count


(a, b) = input('').split()
counter = 1
while True:
	lastRes = int(a) * counter
	if str(lastRes)[-1:] == '0':
		print(str(counter))
		break
	if str(lastRes)[-1:] == b:
		print(str(counter))
		break
	counter += 1


def min_num_shovels(k, r):
	for i in range(1, 11):
		q = k * i // 10
		if k * i % 10 == 0 or k * i - (10 * q + r) == 0:
			return i

def main():
	(k, r) = map(int, input().split())
	print(min_num_shovels(k, r))
main()


(k, r) = map(int, input().split())
l = 100000
p = 100000
if r % k == 0:
	l = r / k
if 10 % k == 0:
	p = 10 / k
mins = min(l, p)
s = 1
a = 0
b = r
while s == 1:
	a = a + 10
	if a % k == 0:
		l = a / k
		s = s + 1
	b = b + 10
	if b % k == 0:
		p = b / k
		s = s + 1
mins = min(mins, min(l, p))
print(int(mins))


n = list(map(int, input().split()))
s = 0
while True:
	s = s + 1
	z = n[0] * s
	v = str(z)
	if v[-1] == '0' or v[-1] == str(n[1]):
		print(s)
		break


(k, r) = map(int, input().split())
val = 1
while val <= 9:
	if val * k % 10 == 0 or val * k % 10 == r:
		print(val)
		break
	else:
		val = val + 1


(k, r) = list(map(int, input().split()))
if k % 10 == 0 or k == r or str(k)[-1] == str(r):
	print(1)
elif k % 5 == 0:
	print(2)
else:
	for i in range(1, 11):
		c = str(int(str(k)[-1]) * i)[-1]
		if c == str(r) or c == '0':
			print(i)
			break


x = input().split()
k = int(x[0])
f = k
r = int(x[1])
counter = 1
while True:
	if k % 10 == r or k % 10 == 0:
		break
	counter += 1
	k += f
print(counter)


(k, r) = input().split()
k = int(k)
r = int(r)
shovels = 1
while True:
	price = shovels * k
	if price % 10 == r or price % 10 == 0:
		break
	else:
		shovels += 1
print(shovels)


from sys import stdin, stdout
input = stdin.readline

def write(n, sep='\n'):
	stdout.write(str(n))
	stdout.write(sep)

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

def ed(n):
	return str(n)[-1]
(k, r) = input().split()
k = int(k)
t = k
while ed(t) != r and ed(t) != '0':
	t = t + k
print(t // k)