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

print(n)
859b7d5571bb497a051705ddfbe81b08c0a8e7f7
<mask token>

<mask token>
while k * n % 10 not in [0, r]:
    n += 1
print(n)

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())
n = 1
while (k * n) % 10 not in [0, r]:
    n += 1

print(n)