You have a fraction $\frac{a}{b}$. You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.


-----Input-----

The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 10^5, 0 ≤ c ≤ 9).


-----Output-----

Print position of the first occurrence of digit c into the fraction. Positions are numbered from 1 after decimal point. It there is no such position, print -1.


-----Examples-----
Input
1 2 0

Output
2
Input
2 3 7

Output
-1


-----Note-----

The fraction in the first example has the following decimal notation: $\frac{1}{2} = 0.500(0)$. The first zero stands on second position.

The fraction in the second example has the following decimal notation: $\frac{2}{3} = 0.666(6)$. There is no digit 7 in decimal notation of the fraction.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Mathematics


Solutions:
(a, b, c) = input().split()
(a, b, c) = (int(a), int(b), int(c))
rem1 = -1
flag = 0
count = 0
d = a % b
while d != rem1 and count <= 1000000:
	rem1 = d % b
	count += 1
	d = d * 10
	q = d // b
	if q == c:
		print(count)
		flag = 1
		break
	d = d % b
if flag == 0:
	print(-1)


from decimal import *
getcontext().prec = 10000
(a, b, c) = map(int, input().split())
c = str(c)
d = str(Decimal(a) / Decimal(b)).split('.')[1][:9999]
while b % 2 == 0:
	b /= 2
while b % 5 == 0:
	b /= 5
if b == 1:
	d += '0'
if c in d:
	print(d.index(c) + 1)
else:
	print(-1)


from decimal import *
getcontext().prec = 300
split_strings = input().split()
[a, b, c] = map(lambda x: int(x), split_strings)
a = Decimal(a)
b = Decimal(b)
decimal = a / b * 10
for i in range(1, 300):
	ones = int(decimal)
	fractional = decimal % 1
	if ones == c:
		print(i)
		exit()
	decimal = fractional * 10
print(-1)


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


from decimal import Decimal, getcontext
getcontext().prec = 123456
o = input().split(' ')
a = Decimal(o[0])
b = Decimal(o[1])
c = Decimal(o[2])
d = str(a / b).split('.')
if len(d) == 2:
	d = d[1]
	for (p, q) in enumerate(d):
		if int(q) == int(c):
			if p == 123455:
				print(-1)
			else:
				print(p + 1)
			exit()
	if int(c) == 0 and len(d) < 123456:
		print(len(d) + 1)
		exit()
	print(-1)
	exit()
elif c == 0:
	print(1)
else:
	print(-1)


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


(n, m, r) = [int(x) for x in input().split()]
c = 0
k = 0
for i in range(500):
	c += 1
	n *= 10
	d = n // m
	d = d % 10
	if d == r:
		k = 1
		print(c)
		break
if k == 0:
	print('-1')


V = set()
(a, b, c) = (int(i) for i in input().split())
i = 1
d = -1
shit = True
while a % b not in V:
	a = a % b
	V.add(a)
	a = a * 10
	d = a // b
	if d == c:
		print(i)
		shit = False
		break
	i += 1
if shit:
	print(-1)


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


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


(a, b, c) = map(int, input().split())
ind = 0
a *= 10
s = []
while True:
	num = a // b
	ind += 1
	if num == c:
		print(ind)
		break
	a -= num * b
	if a in s:
		print(-1)
		break
	s.append(a)
	a *= 10


(a, b, c) = map(int, input().split())
seen = set()
r = -1
d = 0
while True:
	if a < b:
		a *= 10
	r = a // b
	a = a % b
	d += 1
	if r == c:
		print(d)
		break
	elif a not in seen:
		seen.add(a)
	else:
		print(-1)
		break


from decimal import *
import math
getcontext().prec = 100000
(a, b, c) = list(map(int, input().split()))
f = str(Decimal(a) / Decimal(b))
if len(f) < 100000:
	f = f + '0'
suc = False
for i in range(2, 10 ** 5):
	if i == len(f):
		break
	if f[i] == str(c):
		print(i - 1)
		suc = True
		break
if not suc:
	print(-1)


import math as m
MAX = 1000000.0

def pos(a, b, c):
	a %= b
	for i in range(1, b + 1):
		a *= 10
		if int(a / b) == c:
			return i
		a %= b
	return -1
(a, b, c) = [int(i) for i in input().split()]
print(pos(a, b, c))


import decimal
decimal.getcontext().prec = 500
(a, b, c) = input().split()
div = decimal.Decimal(a) / decimal.Decimal(b)
div = str(div)
dec = div.find('.')
after_dec = div[dec + 1:]
if len(after_dec) != 500:
	after_dec = after_dec + '0'
z = after_dec.find(c)
if z == -1 or z == 499:
	print(-1)
else:
	print(z + 1)


(a, b, c) = map(int, input().split())
copy = str(a) + '0' * 100000
div = []
i = 0
while True:
	if a == 0:
		if a == c:
			print(i)
			exit()
		break
	if a // b == c and i != 0:
		print(i)
		exit()
	a = int(str(a % b) + copy[i + len(str(b))])
	if a in div:
		if a == c:
			print(i)
			exit()
		break
	else:
		div.append(a)
	i += 1
print(-1)


(a, b, c) = map(int, input().split())
print(([i for i in range(1, int(1000.0)) if a * pow(10, i) // b % 10 == c] + [-1])[0])


import sys
(a, b, c) = map(int, input().split())
i = 1
while i < 1000:
	a *= 10
	cur = a // b
	if cur == c:
		print(i)
		sys.exit()
	a %= b
	i += 1
print(-1)


(a, b, c) = map(int, input().split())
f = 0
d = a
for i in range(b):
	if a < b:
		a *= 10
	if c == a // b:
		f = 1
		if d >= b:
			print(i)
		else:
			print(i + 1)
		break
	else:
		a = a % b
if f == 0:
	print(-1)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
num = []
cnt = 0
while True:
	cnt += 1
	num.append(a)
	n = a * 10 // b
	if n == c:
		break
	a = a * 10 - n * b
	if a in num:
		cnt = -1
		break
print(cnt)


import decimal
decimal.setcontext(decimal.Context(prec=501))
(a, b, c) = map(int, input().split())
i = 0
val = decimal.Decimal(a) / decimal.Decimal(b)
for i in range(1, 501):
	val = val * 10
	if int(val % 10) == c:
		print(i)
		break
if i == 500:
	print('-1')


from decimal import Decimal, getcontext
(a, b, c) = [int(k) for k in input().split(' ') if k]
getcontext().prec = 5000
v = str(Decimal(a) / b).split('.')
if b % 5 == 0 or b % 2 == 0 or b == 1:
	v[1] += '0'
try:
	s = v[1].index(str(c))
	if s == getcontext().prec - 1:
		print(-1)
	else:
		print(len(v[0]) + s)
except:
	print(-1)


from decimal import *
(a, b, c) = input().strip().split()
getcontext().prec = 10000
result = str(Decimal(int(a)) / Decimal(int(b)))
result += '0'
dec = result.find('.')
ans = -1
for i in range(dec + 1, min(10000, len(result))):
	if result[i] == c:
		ans = i - dec
		break
print(ans)


from decimal import *
(a, b, c) = [int(i) for i in input().split()]
getcontext().prec = 1000
x = Decimal(a)
y = Decimal(b)
s = str(x / y)
if len(s) > 1000:
	h = s[2:-1].find(str(c))
else:
	h = s[2:].find(str(c))
if c == 0 and h == -1 and (len(s) < 1000):
	print(len(s) - 1)
else:
	print(h + 1 if h != -1 else -1)


(a, b, c) = [int(i) for i in input().split()]
x_list = []
for i in range(10 ** 5):
	x = a * 10 // b
	y = a * 10 % b
	x_list.append(x)
	a = y
if c in x_list:
	c_position = x_list.index(c) + 1
else:
	c_position = -1
print(c_position)


import sys
(a, b, c) = list(map(int, input().split()))
a = a % b
a *= 10
steps = 0
for i in range(100000):
	d = a // b
	rem = a - b * (a // b)
	for (id, x) in enumerate(str(d)):
		if int(x) == c:
			print(steps + id + 1)
			sys.exit(0)
	steps += len(str(d))
	a = 10 * rem
print(-1)


import decimal
ln = [int(i) for i in input().split(' ')]
a = ln[0]
b = ln[1]
c = ln[2]
oc = -1
for i in range(0, b + 5):
	q = a * 10 // b
	a = a * 10 % b
	if q == c:
		oc = i + 1
		break
print(oc)


(a, b, c) = map(int, input().split())
pos = 0
flag = False
while pos < 10000:
	pos += 1
	a = a * 10
	q = int(a / b)
	if q == c:
		flag = True
		break
	a = a % b
if flag:
	print(pos)
else:
	print(-1)


def long_div(a, b):
	remain = {}
	a *= 10
	while a not in remain:
		remain[a] = True
		d = a // b
		r = a % b
		a = r * 10
		yield d

def solution(a, b, c):
	for (i, d) in enumerate(long_div(a, b)):
		if d == c:
			return i + 1
	return -1
(a, b, c) = map(int, input().split())
print(solution(a, b, c))


from sys import stdin, stdout
from decimal import *
getcontext().prec = 1000
(a, b, c) = list(map(int, stdin.readline().rstrip().split()))
x = str(Decimal(a) / Decimal(b))[2:]
if len(x) == 1000:
	x = x[:-1]
else:
	x = ''.join([x, '0'])
if str(c) in x:
	print(x.index(str(c)) + 1)
else:
	print(-1)


from fractions import Fraction
(a, b, c) = map(int, input().split())
a = a % b
v = -1
for i in range(1, 1000000):
	a = a * 10
	if a // b == c:
		v = i
		break
	a = a % b
print(v)


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


(a, b, c) = map(int, input().split())
a = str(a)
p = 0
d = 0
r = 0
ans = 1
while p != len(a):
	while p != len(a) and d < b:
		d = int(str(d) + a[p])
		p += 1
	while d >= b:
		d -= b
if d == 0:
	if c == 0:
		print(1)
	else:
		print(-1)
else:
	while True:
		d *= 10
		k = 0
		while d >= b:
			k += 1
			d -= b
		if ans == 10 ** 5:
			print(-1)
			break
		if k == c:
			print(ans)
			break
		ans += 1


(a, b, c) = map(int, input().split())
s = set()
a *= 10
i = 1
while True:
	if c == a // b:
		print(i)
		exit()
	a = (a - a // b * b) * 10
	i += 1
	if i > 150000:
		print(-1)
		exit()


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
[a, b, c] = list(map(int, input().split()))
cnt = 1
for _ in range(1000000):
	a *= 10
	d = a // b
	r = a % b
	if d == c:
		print(cnt)
		exit(0)
	a = r
	cnt += 1
print(-1)


(a, b, c) = map(int, input().split())
a = a % b
cnt = 1
while cnt <= b:
	a *= 10
	if a // b == c:
		print(cnt)
		exit()
	a %= b
	cnt += 1
print(-1)


__author__ = 'smart131'
(a, b, c) = map(int, input().split())
r = a % b
u = []
for i in range(b):
	u.append(10 * r // b)
	r = 10 * r % b
ans = -2
i = 0
while i < b:
	if u[i] == c:
		ans = i
		i += b
	i += 1
print(ans + 1)


(a, b, c) = map(int, input().split())
a %= b
visited = set()
result = -1
i = 1
while True:
	if a * 10 in visited:
		break
	visited.add(a * 10)
	tmp = a * 10 // b
	if tmp == c:
		result = i
		break
	a = a * 10 % b
	i += 1
print(result)


(a, b, c) = map(int, input().split())
a %= b
if a == 0:
	if c == 0:
		print(1)
	else:
		print(-1)
	exit()
p = 0
h = set()
ans = -1
while 1:
	a *= 10
	p += 1
	nm = a // b
	if nm == c:
		ans = p
		break
	if a - b * nm in h:
		break
	h.add(a - b * nm)
	a = a - b * nm
print(ans)


(a, b, c) = list(map(int, input().split()))
pos = -1
for i in range(1, 309):
	if int(a * pow(10, i) // b) % 10 == c:
		pos = i
		break
print(pos)


def main():
	(a, b, c) = map(int, input().split())
	a %= b
	a += b
	if a == 0:
		if c == 0:
			print(1)
		else:
			print(-1)
		exit(0)
	a = str(a * 10 ** 100000 // b)
	for i in range(1, len(a)):
		if int(a[i]) == c:
			print(i)
			exit(0)
	print(-1)
main()


(a, b, c) = map(int, input().split())
a %= b
remains = set()
pos = -1
loc = 0
while True:
	loc += 1
	a *= 10
	remain = a % b
	if a // b == c:
		pos = loc
		break
	if remain in remains:
		break
	else:
		remains.add(remain)
	a = remain
print(pos)


(a, b, c) = map(int, input().split())
k = 10000
s = ''
z = a
while k:
	k -= 1
	s += str(z * 10 // b)
	z = z * 10 % b
if str(c) in s:
	print(s.index(str(c)) + 1)
else:
	print(-1)


(a, b, c) = map(int, input().split())
N = 100000
MUL = int(1000000.0)
pos = 0
can = False
c = str(c)
for i in range(N):
	a *= MUL
	s = '%.6f' % (a // b / MUL)
	point = s.find('.')
	s = s[point + 1:]
	a = a % b
	cur_p = s.find(c)
	if cur_p == -1:
		pos += len(s)
	else:
		can = True
		pos += cur_p
		break
if can:
	print(pos + 1)
else:
	print(-1)


(a, b, c) = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
find = False
i = 0
while not find:
	i += 1
	a *= 10
	d = a // b
	if d == c:
		print(i)
		find = True
	a -= b * d
	if i > b:
		print(-1)
		break


(a, b, pos) = map(int, input().split())
for i in range(b):
	a *= 10
	c = a // b
	a = a % b
	if c == pos:
		print(i + 1)
		exit()
print('-1')


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


from decimal import *
getcontext().prec = 505
(a, b, c) = [int(i) for i in input().split()]
r = Decimal(a) / Decimal(b)
r = list(str(r))
if len(r) < 405:
	for i in range(3):
		r.append(str(0))
r = r[1:-1]
for i in range(len(r) - 2):
	if r[i + 1] == str(c):
		print(i + 1)
		exit(0)
print(-1)


from decimal import *
getcontext().prec = 200000
[a, b, c] = list(map(int, input().split()))
q = b
while q % 2 == 0:
	q //= 2
while q % 5 == 0:
	q //= 5
ans = Decimal(a) / Decimal(b)
x = str(ans)
y = -1
p = 0
f = 0
g = 0
for u in x:
	if f == 1:
		if int(u) == c:
			y = p
			break
		p += 1
		if p == b + 1:
			g = 1
			break
	if u == '.':
		p = 1
		f = 1
if c == 0:
	if q == 1 and g == 0:
		y = p
print(y)


(a, b, c) = map(int, input().split())
for i in range(1, 1000000):
	(d, a) = divmod(a * 10, b)
	if d == c:
		print(i)
		exit()
print(-1)


from fractions import Fraction
(a, b, c) = tuple(map(int, input().split()))
f = Fraction(a, b)
for i in range(900):
	for j in range(10):
		if f < Fraction(j + 1, 10):
			if j == c:
				print(i + 1)
				exit(0)
			f -= Fraction(j, 10)
			f *= 10
			break
print(-1)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = 10 ** 10000 * a // b
x = 10 ** (10000 - 1)
for i in range(1, 1001, 1):
	if d // x == c:
		print(i)
		exit(0)
	d %= x
	x //= 10
print(-1)


import decimal
(a, b, c) = map(int, input().split())
decimal.getcontext().prec = 3 * b + 100
s = str(decimal.Decimal(a) / decimal.Decimal(b)).ljust(3 * b + 100, '0')
r = s.find(str(c), 2, 2 * b + 8) - 1
if r == -2:
	print(-1)
else:
	print(r)


(q, w, e) = map(int, input().split())
i = 1
q *= 10
while q // w != e:
	q %= w
	q *= 10
	i += 1
	if i > 1000:
		i = -1
		break
print(i)


(a, b, c) = map(int, input().split(' '))
a = a % b
i = 1
while i <= b:
	if a == 0:
		if c == 0:
			print(i)
			exit()
		else:
			print(-1)
			exit()
	if a < b:
		a *= 10
	while a < b:
		if c == 0:
			print(i)
			exit()
		a *= 10
		i += 1
	d = a // b
	if d == c:
		print(i)
		exit()
	a -= d * b
	i += 1
print(-1)


import sys
(a, b, c) = map(int, sys.stdin.readline().split())
flag = 0
for i in range(1, b + 1):
	a = a * 10
	if a // b == c:
		flag = 1
		break
	a = a % b
if flag:
	print(i)
else:
	print(-1)


import sys
import math

def main():
	(a, b, c) = map(int, sys.stdin.readline().strip().split())
	for i in range(b):
		a *= 10
		pos = a // b
		a = a % b
		if c == pos:
			print(i + 1)
			return 0
	print(-1)
main()


arr = list(map(int, input().split()))
a = arr[0]
b = arr[1]
c = arr[2]
seq = []
for i in range(0, 2 * b):
	seq.append(a * 10 // b)
	a = a * 10 % b
if c in seq:
	print(seq.index(c) + 1)
else:
	print(-1)


def main():
	(a, b, c) = map(int, input().split())
	a -= a // b * b
	for i in range(1, 1000000):
		a *= 10
		quo = a // b
		if quo == c:
			print(i)
			exit()
		a -= quo * b
	print(-1)
	return 0
main()


(a, b, c) = map(int, input().split())
c = str(c)
s = ''
a %= b
a *= 10
v = [a]
while True:
	s += str(a // b)
	a %= b
	a *= 10
	if c in s:
		print(s.find(c) + 1)
		exit()
	if a in v:
		print(-1)
		exit()
	else:
		v.append(a)


import sys
(a, b, c) = map(int, input().split())
if a // b:
	a %= b
p = 0
pp = [0] * 10
i = 0
while p < 10:
	i += 1
	a %= b
	a *= 10
	if i > 100000:
		break
	if a // b == c:
		print(i)
		sys.exit(0)
	if pp[a // b] == 0:
		pp[a // b] = 1
		p += 1
print(-1)


from decimal import *
N = 100100
getcontext().prec = N
(a, b, c) = input().split()
p = str((Decimal(a) / Decimal(b)).quantize(Decimal(10) ** (-N)))[2:-10].find(str(c))
if p >= 0:
	p += 1
print(p)


vars = [int(x) for x in input().split()]
a = vars[0]
b = vars[1]
c = vars[2]
h = -1
for x in range(1, 1000):
	if a * pow(10, x) // b % 10 == c:
		print(x)
		h = 0
		break
if h != 0:
	print(h)


(a, b, c) = [int(x) for x in input().split()]
mp = {}
ans = False
i = 1
rem = a % b
while rem != 0 and rem not in mp:
	mp[rem] = 1
	rem = rem * 10
	r = rem // b
	if r == c:
		ans = True
		break
	rem %= b
	i += 1
if rem == 0:
	if c == 0:
		print(i)
	else:
		print(-1)
elif ans:
	print(i)
else:
	print(-1)


(a, b, c) = map(int, input().split())
dec = []
for j in range(10 ** 5):
	a *= 10
	dec.append(a // b)
	a %= b
i = 0
for i in range(len(dec)):
	if c == dec[i]:
		print(i + 1)
		break
	i += 1
if i == len(dec):
	print(-1)


(a, b, c) = list(map(int, input().split()))
store = []
cnt = 1
while cnt < 1000:
	a = a * 10
	d = a // b
	store.append(d)
	a = a % b
	cnt += 1
pos = -111
try:
	pos = store.index(c)
except ValueError:
	pos = -1
print(pos if pos == -1 else pos + 1)


import sys
(a, b, c) = (int(x) for x in input().split())
for i in range(450):
	a *= 10
	if a // b == c:
		print(i + 1)
		print(exit(code=0))
	a %= b
print(-1)


(a, b, c) = map(int, input().split())
k = 0
d = -1
s = set()
while d != c:
	if a in s:
		print(-1)
		exit()
	s.add(a)
	d = a * 10 // b
	a = a * 10 % b
	k += 1
print(k)


(a, b, c) = [int(i) for i in input().split()]
d = 0
while d < 1000:
	d += 1
	if str(a * 10 ** d // b)[-1] == str(c):
		print(d)
		exit()
print(-1)


(a, b, c) = map(int, input().split())
cnt = 0
l = []
for i in range(b + 3):
	l.append(0)
k = a % b
f = 0
while l[k] == 0:
	if k == 0 and c == 0:
		cnt += 1
		f = 1
		break
	elif k == 0:
		break
	i = 0
	l[k] = 1
	while k * 10 ** i < b:
		i += 1
	k = k * 10 ** i
	if i > 1 and c == 0:
		f = 1
		cnt += 1
		break
	cnt += i
	if k // b == c:
		f = 1
		break
	k = k % b
if f == 1:
	print(cnt)
else:
	print('-1')


(x, y, c) = map(int, input().split())
for i in range(10 ** 8):
	x = x * 10
	if x // y == c:
		print(i + 1)
		break
	x %= y
else:
	print(-1)


(a, b, c) = map(int, input().split())
for i in range(200000):
	if a >= b:
		x = a // b
		a = a % b
		a *= 10
	else:
		x = 0
		a *= 10
	if x == c and i > 0:
		print(i)
		break
else:
	print(-1)


from decimal import *
(a, b, c) = map(int, input().split(' '))
getcontext().prec = 10000
s = str(Decimal(a) / Decimal(b))
s += '0'
l = s.split('.')
if l[1].find(str(c)[0]) < 9000 and l[1].find(str(c)[0]) != -1:
	print(l[1].find(str(c)[0]) + 1)
else:
	print(-1)


def div_step(kal, bol):
	zero_add = 0
	it = 0
	while kal < bol:
		kal = int(str(int(kal)) + '0')
		it += 1
		if it > 1:
			zero_add += 1
	tmp = int(kal / bol)
	new_kal = kal - bol * tmp
	res = str(tmp)
	for i in range(zero_add):
		res = '0' + res
	return (new_kal, res)

def check(full, mem):
	s = ''
	for i in range(len(mem)):
		s = s + mem[i]
	if len(full) < 2 * len(s):
		return True
	for i in range(len(full) - 2 * len(s) + 1):
		if full[i:i + len(s)] == s:
			return False
		else:
			return True

def main():
	(a, b, c) = [float(x) for x in input().split()]
	after_comma = ''
	count = 0
	tmp = int(a / b)
	kal = a - b * tmp
	mem = []
	if kal == 0:
		if c == 0:
			print(1)
		else:
			print(-1)
		return
	c = int(c)
	while 1:
		(kal, res) = div_step(kal, b)
		mem.append(res)
		if len(mem) > 4:
			mem.pop(0)
		for i in range(len(res)):
			count += 1
			if res[i] == str(c):
				print(count)
				return
			if kal == 0:
				if c == 0:
					print(count + 1)
				elif str(c) == res[len(res) - 1]:
					print(len(res))
				else:
					print(-1)
				return
		after_comma = after_comma + res
		go = check(after_comma, mem)
		if not go:
			print(-1)
			return
	print(count)
main()


def encontrar(a, b, c):
	a = a % b
	for i in range(1, b + 1):
		a = a * 10
		if int(a / b) == c:
			return i
		a = a % b
	return -1
fraccion = input()
fraccion = fraccion.split()
a = int(fraccion[0])
b = int(fraccion[1])
c = int(fraccion[2])
print(encontrar(a, b, c))


(a, b, c) = map(int, input().split())
a %= b
k = 0
for i in range(1000):
	cf = 0
	while cf < 9 and (k * 10 + cf + 1) * b <= a * 10:
		cf += 1
	if cf == c:
		print(i + 1)
		return
	k = k * 10 + cf
	a *= 10
print(-1)


import decimal
(a, b, digit) = map(int, input().split())
p = 100002
decimal.getcontext().prec = p
x = str(decimal.Decimal(a) / decimal.Decimal(b))[1:].ljust(p, '0')[:-1]
print(x.find(str(digit)))


(a, b, c) = list(map(int, input().strip().split()))
a = a % b
for i in range(10 * b):
	a *= 10
	d = a // b
	a = a % b
	if c == d:
		print(i + 1)
		break
else:
	print(-1)


import math as m
MAX = 1000000.0
(a, b, c) = [int(i) for i in input().split()]
i = 0
for i in range(1, int(MAX)):
	d = m.modf(a * 10 / b)[1]
	if d == c:
		break
	a = a * 10 % b
print(i if i != MAX - 1 else -1)


(a, b, c) = map(int, input().split())
s = set()
ans = ''
while 1:
	if a in s:
		break
	elif a == 0:
		ans += '0'
		break
	elif a < b:
		s.add(a)
		a *= 10
		ans += '0'
	else:
		s.add(a)
		ans += str(a // b)
		a %= b
		a *= 10
c = str(c)
ans = '.' + ans[1:]
if c not in ans:
	print(-1)
else:
	print(ans.index(c))


(a, b, c) = map(int, input().split())
res = ''
vara = [0 for i in range(1000001)]
while True:
	cnt = 0
	while a < b:
		a = a * 10
		cnt += 1
		if cnt > 1:
			res += '0'
	vara[a] += 1
	if vara[a] == 2:
		break
	res += str(a // b)
	a = a % b
	if a == 0:
		res += '0'
		break
c = str(c)
for i in range(len(res)):
	if c == res[i]:
		print(i + 1)
		break
else:
	print(-1)


(a, b, c) = list(map(int, input().split()))
used = set([a])
a *= 10
i = 1
while True:
	if a // b == c:
		print(i)
		return
	a %= b
	if a in used:
		break
	used |= set([a])
	a *= 10
	i += 1
print(-1)


(a, b, c) = (int(x) for x in input().split(' '))
res = '.'
for i in range(b):
	s = a // b
	d = a % b
	if s == 0:
		a = a * 10
	if i != 0:
		res += str(s)
	a = d * 10
	if s == 1 and d == 0:
		res += '0'
		break
if b == 2:
	res += '0'
print(res.find(str(c)))


(a, b, c) = map(int, input().split())
t = a
(q, r) = divmod(t, b)
for i in range(1, 10 ** 5 + 1):
	(q, r) = divmod(r * 10, b)
	if q == c:
		print(i)
		exit()
else:
	print(-1)


read = lambda : map(int, input().split())
(a, b, c) = read()
x = str(int(a * 10 ** 1000 // b) + 10 ** 1000)
ans = -1
m = min(950, len(x))
for i in range(1, m):
	if x[i] == str(c):
		ans = i
		break
print(ans)


def pos(a, b, c):
	a %= b
	for i in range(1, b + 1):
		a *= 10
		if int(a / b) == c:
			return i
		a %= b
	return -1
print(pos(*[int(i) for i in input().split()]))


(a, b, c) = map(int, input().split())
flag = -1
a = a % b
for i in range(1, 100000):
	temp = a * 10 // b
	if temp == c:
		flag = i
		break
	a = a * 10 % b
print(flag)


(a, b, c) = list(map(int, input('').strip().split()))
occur = dict()
count = 0
for i in range(10 ** 6):
	count += 1
	a *= 10
	occurs = a // b
	occur[a] = occurs
	left = a % b
	if occurs == c:
		print(count)
		break
	elif left * 10 in occur:
		print(-1)
		break
	else:
		a = a % b


from decimal import *
getcontext().prec = 2048
getcontext().rounding = ROUND_DOWN
(num, denom, target) = [int(x) for x in input().split()]
a = Decimal(num) / Decimal(denom)
a = str(a)
a = a[a.find('.'):]
if len(a) < 2047:
	a = a + '0'
print(a.find(str(target)))


def first(a, b, c):
	a %= b
	for i in range(1, b + 1):
		a = a * 10
		if int(a / b) == c:
			return i
		a %= b
	return -1
(a, b, c) = map(int, input().split())
print(first(a, b, c))


from sys import stdin, stdout
(a, b, c) = map(int, stdin.readline().split())
sze = 10 ** 5
for i in range(1, sze + 1):
	cur = a * 10 // b
	a = a * 10 % b
	if cur == c:
		stdout.write(str(i))
		break
else:
	stdout.write('-1')


ar = []
ar = input().split()
a = int(ar[0])
b = int(ar[1])
c = int(ar[2])
d = 1
for i in range(1000):
	d *= 10
d = d * a
d = d // b
string = str(d)
while len(string) < 1000:
	string = '0' + string
i = 0
for dig in map(int, string):
	i += 1
	if dig == c:
		break
if i == 1000:
	print(-1)
else:
	print(i)


import sys

def long_division(dividend, divisor):
	ans = ''
	index = 0
	cur_dividend = int(str(dividend)[index:index + 1].ljust(1, '0'))
	dividends = set()
	while cur_dividend not in dividends:
		dividends.add(cur_dividend)
		(div, mod) = divmod(cur_dividend, divisor)
		yield div
		index += 1
		cur_dividend = mod
		cur_dividend = int(str(cur_dividend) + str(dividend)[index:index + 1].ljust(1, '0'))
	return None

def decimal_part(dividend, divisor):
	for i in long_division(dividend, divisor):
		if dividend == 0:
			yield i
		dividend //= 10

def solve(a, b, c):
	for (index, v) in enumerate(decimal_part(a, b)):
		if v == c:
			return index + 1
	return -1
print(solve(*map(int, input().split())))


from decimal import *
context = Context(prec=10000)
setcontext(context)
(a, b, c) = map(int, input().split())
string = str(Decimal(a) / Decimal(b))
(flag, ans) = (0, 0)
for i in range(len(string)):
	if string[i] == '.':
		flag = 1
	elif flag == 1:
		ans += 1
		if string[i] == str(c) and i < 9999:
			print(ans)
			flag = -1
			break
if Decimal(float(string)) * Decimal(b) == a and c == 0:
	print(ans + 1)
elif flag == 1:
	print(-1)


(a, b, c) = map(int, input().split())
cntZeroes = 0
tenPw = 1
for i in range(1, 1000):
	tenPw *= 10
	if 1 * b <= a * tenPw:
		break
	cntZeroes += 1
for i in range(1000):
	a = a * 10
a //= b
if c == 0:
	if cntZeroes > 0:
		print(1)
		exit(0)
arr = []
while a > 0:
	arr.append(a % 10)
	a //= 10
arr.reverse()
for i in range(len(arr)):
	if arr[i] == c:
		print(cntZeroes + i + 1)
		exit(0)
print(-1)


import math
from decimal import *
getcontext().prec = 400
(a, b, c) = [int(x) for x in input().split(' ')]
d = Decimal(a) / Decimal(b)
ans = -1
for i in range(1, 300):
	d = 10 * d
	last = int(d)
	d = d - last
	if last == c:
		ans = i
		print(ans)
		break
if ans == -1:
	print(ans)


(a, b, c) = [int(x) for x in input().split()]
count = 0
for x in range(500):
	count += 1
	m = int(a * 10 / b)
	if m == c:
		print(count)
		break
	a = a * 10 % b
else:
	print(-1)


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(a, b, c) = M()
l = [0] * b
i = 1
while True:
	if 10 * a % b == 0:
		if c == 0:
			print(i + 1)
			exit()
	if l[10 * a % b] == 0:
		l[10 * a % b] += 1
		if 10 * a // b == c:
			print(i)
			exit()
		a = 10 * a % b
	elif l[10 * a % b] != 0:
		print(-1)
		exit()
	i += 1


import decimal
d_context = decimal.getcontext()
d_context.prec = 1000000
(a, b, c) = input().split()
a = decimal.Decimal(a)
b = decimal.Decimal(b)
s = str(a / b)
ans = -1
try:
	idx = s.index('.')
	if len(s) < 1000000 - 2:
		s = s + '00'
	for i in range(idx + 1, len(s) - 1):
		if s[i] == c:
			ans = i - idx
			break
except:
	pass
print(ans)


import sys
(a, b, c) = [int(x) for x in input().split(' ')]
mp = 10
for i in range(1, 12500):
	cd = int(mp * a // b) % 10
	if cd == c:
		print(i)
		sys.exit(0)
	mp *= 10
print('-1')


(a, b, c) = map(int, input().split())
a = a % b
count = 0
l = 0
m = 0
n = 0
k = 0
while True:
	n = a
	a *= 10
	k = a // b
	a = a % b
	count += 1
	if k == c:
		l += 1
		print(count)
		break
	if a == 0 and c != 0:
		m += 1
		break
	if n == k and c == k:
		print(count - 1)
		break
	if n == a:
		m += 1
		break
	if count > b:
		m += 1
		break
if m > l:
	print('-1')


from sys import *
from collections import *
from math import *
from random import *
from datetime import date

def lStr(d=' '):
	return input().split(' ')

def lInt(d=' '):
	return [int(i) for i in input().split(d)]

def lDec(d=' '):
	return [float(i) for i in input().split(d)]
(a, b, c) = lInt()
(i, f) = (1, 1)
check = set()
while a:
	d = 0
	if a >= b:
		if a in check:
			(print(-1), exit(0))
		check.add(a)
		f = 1
		(d, a) = divmod(a, b)
	else:
		a *= 10
		if f:
			f = 0
			continue
	if d == c:
		(print(i), exit(0))
	i += 1
print(i if c == 0 else -1)


def divide(a, b):
	assert b > 0
	integer = a // b
	remainder = a % b
	seen = {remainder: 0}
	digits = []
	while True:
		remainder *= 10
		digits.append(remainder // b)
		remainder = remainder % b
		if remainder in seen:
			where = seen[remainder]
			return (integer, digits[:where], digits[where:])
		else:
			seen[remainder] = len(digits)
ip = input()
lst = list(map(int, ip.split(' ')))
a = lst[0]
b = lst[1]
c = lst[2]
(i, f, r) = divide(a, b)
for i in range(len(r)):
	f.append(r[i])
for i in range(len(f)):
	if c == f[i]:
		print(i + 1)
		exit()
print(-1)


(a, b, c) = list(map(int, input().split()))
s = []
while a != 0:
	t = 0
	while a < b:
		if t == 1:
			s.append([0, 0])
			if c == 0:
				print(len(s))
				return
		a *= 10
		t = 1
	d = a // b
	a %= b
	if [d, a] in s:
		print(-1)
		return
	elif d == c:
		print(len(s) + 1)
		return
	s.append([d, a])
	if a == 0 and c == 0:
		print(len(s) + 1)
		return
print(-1)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

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

def lin():
	return list(map(int, stdin.readline().split()))
(a, b, c) = lin()
ch = 0
ch1 = 0
count = 0
ch = a // b
(a, b) = (a % b * 10, b)
while count < 10000:
	count += 1
	if ch == a // b:
		ch1 += 1
	else:
		ch1 = 0
	ch = a // b
	(a, b) = (a % b * 10, b)
	if ch == c:
		print(count)
		break
else:
	if ch == c:
		print(count)
	print(-1)


def convert(numerator, denominator):
	integer_part = str(numerator // denominator)
	ans = ''
	l = dict()
	i = 0
	numerator = numerator % denominator
	l[numerator] = i
	i += 1
	if numerator == 0:
		return '0'
	while True:
		if numerator == 0:
			return str(ans) + '0'
		(digit, numerator) = divmod(numerator * 10, denominator)
		ans += str(digit)
		if numerator not in l:
			l[numerator] = i
			i += 1
		else:
			return ''.join((str(ans[:l[numerator]]), str(ans[l[numerator]:])))
(a, b, c) = map(int, input().split())
s = convert(a, b)
try:
	print(s.index(str(c)) + 1)
except ValueError:
	print(-1)


def get_int(string, n):
	i = j = k = 0
	for s in string:
		k += 1
	for s in string:
		if i == n - 1:
			break
		if s == ' ':
			i += 1
		j += 1
	i = 0
	while j < k:
		if string[j] == ' ':
			break
		i = 10 * i + int(string[j])
		j += 1
	return i
x = input()
a = get_int(x, 1)
b = get_int(x, 2)
c = get_int(x, 3)
n = -1
for i in range(1, 10000):
	a *= 10
	if a // b % 10 == c:
		n = i
		break
print(n)


def position(a, b, c):
	for i in range(1, 200000):
		if a * 10 // b == c:
			return i
		a = a * 10 % b
	return -1
(A, B, C) = [int(j) for j in input().split()]
print(position(A, B, C))


from math import log10
(a, b, c) = map(int, input().split())
for i in range(1, 300):
	a *= 10
	x = int(a / b)
	if x == c:
		print(i)
		exit()
	a -= x * b
print(-1)


(a, b, c) = map(int, input().split())
seen = False
i = 0
for j in range(100004):
	a *= 10
	i += 1
	if a // b == c:
		print(i)
		seen = True
		break
	a %= b
if not seen:
	print(-1)


(a, b, c) = map(int, input().strip().split())
a = a % b
i = 1
while i < 100000:
	t = int(a * 10 / b)
	if t == c:
		break
	a = a * 10 - t * b
	i += 1
if i >= 100000:
	print(-1)
else:
	print(i)


(a, b, c) = [int(i) for i in input().split()]
from decimal import Decimal, getcontext
getcontext().prec = 10000

def main():
	result = round(Decimal(a) / Decimal(b), 10000)
	string = str(result)
	string = string[2:]
	comp = str(c)
	for i in range(10000):
		if string[i] == comp:
			print(i + 1)
			return 0
		if i == 9998:
			print(-1)
			return 0
main()


from __future__ import division
import math
A = list(map(int, input().split()))
a = A[0]
b = A[1]
c = A[2]
a %= b
index = 0
for i in range(1, b + 1):
	a = a * 10
	if int(a / b) == c:
		index = i
		break
	a %= b
if index != 0:
	print(index)
else:
	print(-1)


from decimal import *
getcontext().prec = 10000
(a, b, c) = map(int, input().split())
d = Decimal(a) / Decimal(b)
s = str(d)[2:]
if len(s) > 900:
	s = s[:-1]
else:
	s += '0'
try:
	ans = s.index(str(c))
except ValueError:
	print(-1)
else:
	print(ans + 1)


def short_division(dividend: int, divisor: int) -> (int, int):
	remainder = dividend
	quotient = 0
	while remainder >= divisor:
		remainder -= divisor
		quotient += 1
	return (quotient, remainder)

def long_division(dividend: int, divisor: int, number_of_digits, target) -> (int, int):
	if divisor == 0:
		raise ZeroDivisionError('The divisor must be non-zero integer')
	if dividend == 0:
		return '0'
	positive = dividend > 0 and divisor > 0 or (dividend < 0 and divisor < 0)
	absdividend = abs(dividend)
	absdivisor = abs(divisor)
	quotient = '0'
	pointer = 0
	s = str(absdividend)
	period_length = absdivisor
	period_step = 0
	if absdividend >= absdivisor:
		period_started = False
		remainder = 0
	else:
		remainder = absdividend
		period_started = True
	is_found = False
	while period_step <= period_length and period_step < number_of_digits:
		if period_started:
			postfix = '0'
		else:
			postfix = s[pointer:pointer + 1]
		if not postfix:
			break
		remainder = int(str(remainder) + postfix)
		if remainder < absdivisor and (not period_started):
			if 0 == target:
				is_found = True
				break
			quotient += '0'
			pointer += 1
			continue
		elif remainder < absdivisor and period_started:
			if 0 == target:
				is_found = True
				break
			quotient += '0'
			period_step += 1
			continue
		(temp_quotient, temp_remainder) = short_division(remainder, absdivisor)
		quotient += str(temp_quotient)
		remainder = temp_remainder
		if temp_quotient == target:
			is_found = True
			break
		if remainder == 0 and period_started:
			period_step += 1
			break
		elif remainder == 0 and (not period_started):
			pointer += 1
			continue
		if period_started:
			period_step += 1
		else:
			pointer += 1
		if remainder < absdivisor and (not period_started) and (pointer >= len(s)):
			period_started = True
	if is_found:
		return period_step + 1
	else:
		if target == 0:
			if period_step < period_length:
				return period_step + 1
		return -1
s = input()
(a, b, c) = [int(x) for x in s.split()]
p = long_division(a, b, b, c)
print(p)


from decimal import *

def main():
	getcontext().prec = 500
	(a, b, c) = map(int, input().split())
	d = str(Decimal(a) / Decimal(b))
	d += '0' * (502 - len(d))
	cnt = [-2] * 10
	for (idx, item) in enumerate(d[2:-1]):
		if cnt[int(item)] == -2:
			cnt[int(item)] = idx
	print(cnt[c] + 1)
main()


from decimal import *
getcontext().prec = 10000

def is_good(num):
	while num % 2 == 0:
		num //= 2
	while num % 5 == 0:
		num //= 5
	return num == 1
(a, b, c) = map(int, input().split())
a %= b
c = str(c)
flag = False
s = str(Decimal(a) / Decimal(b))[2:]
if is_good(b):
	s = s + '00'
for (i, d) in enumerate(s[:-1]):
	if d == c:
		print(i + 1)
		flag = True
		break
if not flag:
	print(-1)


(a, b, k) = input().split(' ')
a = int(a)
b = int(b)
cnt0 = 0
v = a / b
while int(10 * v) == 0:
	v *= 10
	cnt0 += 1
if k == '0' and cnt0 > 0:
	print(1)
	exit(0)
a *= int(10 ** 100000)
a //= b
a = str(a)
l = len(a)
for i in range(l - 100):
	if a[i] == k:
		print(i + 1 + cnt0)
		exit(0)
print(-1)


(a, b, c) = [int(i) for i in input().split(' ')]
a = a % b
f = 1
for i in range(10000):
	if a < b:
		a = 10 * a
		res = a // b
		a = a % b
	if res == c:
		print(i + 1)
		f = 0
		break
	a %= b
if f:
	print(-1)


from decimal import *
getcontext().prec = 300000
(a, b, c) = input().split()
res = str(Decimal(a) / Decimal(b))[1:]
while len(res) < 300001 - 10:
	res += '0'
res = res[:-1]
print(res.find(c))


import sys
import math
(a, b, c) = map(int, sys.stdin.readline().split(' '))
ans = -1
for i in range(1, 1000):
	a = a * 10
	d = a // b
	e = d % 10
	if e == c:
		ans = i
		break
print(ans)


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


from decimal import *
import math
getcontext().prec = 1000000
inputs = [int(x) for x in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
num = Decimal(a) / Decimal(b)
d = str(num)
found = False
where = 0
pos = -2
at = 0
for _ in d:
	if at == 999999:
		break
	if _ == '.':
		found = True
		where = at
		continue
	if found == False:
		continue
	if _ == str(c):
		pos = at - where
		break
	at = at + 1
if pos == -2 and c == 0 and (at < 999999):
	pos = at
print(pos + 1)


(a, b, c) = list(map(int, input().split()))
pos = 1
for i in range(1000000):
	d = 10 * a // b
	a = 10 * a % b
	if c == d:
		print(pos)
		return
	else:
		pos += 1
print(-1)


(a, b, c) = map(int, input().split(' '))
f = False
for i in range(1, 1000):
	a *= 10
	if a // b == c:
		print(i)
		f = True
		break
	a %= b
if f != True:
	print(-1)


(a, b, c) = map(int, input().split())
(q, r) = divmod(a, b)
under = a - b * q
after_decimal_point = ''
for _ in range(b):
	under *= 10
	(q, r) = divmod(under, b)
	under -= b * q
	after_decimal_point += str(q)
location = after_decimal_point.find(str(c))
if location == -1:
	print(-1)
else:
	print(location + 1)


def fun(a, b, c):
	QR = []
	flag = 0
	t = 0
	while flag == 0:
		t = t + 1
		qr = []
		q = int(a * 10 / b)
		r = a * 10 % b
		qr.append(q)
		qr.append(r)
		a = r
		if q == c:
			return t
		if qr in QR:
			flag == 1
			return -1
		QR.append(qr)
(a, b, c) = input('').split(' ', 2)
a = int(a)
b = int(b)
c = int(c)
print(fun(a, b, c))


(a, b, c) = [int(i) for i in input().split()]
while a > b:
	a -= b * (a // b)
t = a / b
s = str(t)
count = 1
while True:
	if 'e' in s:
		count += 1
		a = a * 10
		while a > b:
			a -= b * (a // b)
		t = a / b
		s = str(t)
	else:
		n = s.index('.')
		break
while int(s[n + 1]) != c:
	count += 1
	a = a * 10
	while a > b:
		a -= b * (a // b)
	t = a / b
	s = str(t)
	n = s.index('.')
	if count > 100005:
		count = -1
		break
print(count)


(a, b, c) = [int(j) for j in input().split()]
step = 0
flag = False
x = a * 10
while step < b + 1 and (not flag):
	step += 1
	dig = x // b
	if dig == c:
		print(step)
		flag = True
		break
	x = x % b * 10
if not flag:
	print(-1)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
ans = -1
mn = 10 ** 3000
while 1:
	a *= 10
	ans += 1
	if a >= b:
		break
a = a * mn
a //= b
s = str(a)
k = len(s)
t = 0
i = 0
if c == 0 and ans > 0:
	print(1)
else:
	while 1:
		if i == k:
			break
		elif s[i] == chr(c + 48):
			t = 1
			print(i + ans + 1)
			break
		i += 1
	if t == 0:
		print(-1)


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


from functools import lru_cache
(a, b, c) = tuple(map(int, input().split()))
a *= 10
k = 0
flag = True
while flag:
	k += 1
	d = a // b
	a = a % b * 10
	if c == d:
		flag = False
		print(k)
	if k > 100000:
		print(-1)
		flag = False


from decimal import *
getcontext().prec = 1000
(a, b, c) = map(int, input().split())
if a == b:
	if c == 0:
		print(1)
	else:
		print(-1)
	exit(0)
d = Decimal(a) / Decimal(b)
c = str(c)
s = str(d)
s = s.split('.')[1]
if len(s) > 999:
	s = s[:-1]
cnt = 1
for i in s:
	if i == c:
		print(cnt)
		exit(0)
	cnt += 1
else:
	if c == '0' and cnt != 1000:
		print(cnt)
	else:
		print(-1)


from decimal import *
getcontext().prec = 1000
(a, b, c) = input().split()
a = int(a)
b = int(b)
m = str(format(Decimal(a) / Decimal(b), '.1000f'))
l = m.find('.')
m = m[l:-1]
if c in m:
	print(m.find(c))
else:
	print(-1)


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


(a, b, c) = list(map(int, input().split(' ')))
ret = 0
visited = set()
while True:
	if a in visited:
		print(-1)
		break
	visited.add(a)
	k = a // b
	if k == c and ret > 0:
		print(ret)
		break
	a = a - b * k
	a *= 10
	ret += 1


(a, b, c) = map(int, input().split())
a %= b
cnt = 1
v = [False for i in range(0, 1000000 + 2)]
while True:
	a *= 10
	num = a // b
	if v[a]:
		print(-1)
		exit(0)
	v[a] = True
	if num == c:
		print(cnt)
		exit(0)
	a %= b
	cnt += 1


from decimal import *
getcontext().prec = 10 ** 5 + 500
(a, b, c) = map(int, input().split())
r = Decimal(a) / Decimal(b)
r = (str(r) + '0' * 100).split('.')[1][:10 ** 5]
if str(c) not in r:
	print(-1)
else:
	print(r.index(str(c)) + 1)


import math
(a, b, c) = map(int, input().split())
ans = 0
while ans < 1000:
	ans += 1
	if str(a * 10 ** ans // b)[-1] == str(c):
		print(ans)
		exit()
print(-1)


(a, b, c) = map(int, input().split())
r = a % b
t = b
cnt = 1
f = 0
while t != 0:
	r *= 10
	k = r // b
	r = r % b
	if k == c:
		f = 1
		break
	cnt += 1
	t -= 1
if f:
	print(cnt)
else:
	print(-1)


import sys
input = sys.stdin.readline
(a, b, c) = list(map(int, input().split()))
f = 0
for i in range(b + 5):
	d = a * 10 // b
	e = a * 10 % b
	if d == c:
		f = 1
		print(i + 1)
		break
	else:
		a = e
if f == 0:
	print(-1)


(a, b, c) = map(int, input().strip().split())
a %= b
save = a
a = a * 10 ** 1000 // b
len = 0
pos = -1
while a > 0:
	if a % 10 == c:
		pos = len
	a //= 10
	len += 1
if save * 10 < b and c == 0:
	print(1)
else:
	print(1000 - pos if pos != -1 else -1)


(a, b, c) = map(int, input().split())
fraction = ''
for i in range(500):
	if a == 0:
		fraction += '0'
		break
	a = a * 10
	while True:
		if a >= b:
			break
		a = a * 10
		fraction += '0'
	fraction += str(int(a / b))
	a = a % b
c = str(c)
if c in fraction:
	print(fraction.index(c) + 1)
	quit()
print('-1')


(a, b, c) = map(int, input().split())
a = a % b * 10
t = 0
r = 0
flag = 0
while r < b:
	r += 1
	t = a // b
	if t == c:
		flag = r
		break
	a %= b
	a *= 10
if flag:
	print(flag)
else:
	print(-1)


from decimal import *
(a, b, c) = map(int, input().split())
getcontext().prec = 100000
dec = Decimal(a) / Decimal(b)
t = -1
s = str(dec)
y = -1
for i in range(100000):
	st = '0'
	if i < len(s):
		st = s[i]
	if st == '.':
		y = i
	if st == str(c):
		if y >= 0:
			t = i - y
			break
print(t)


(a, b, n) = list(map(int, input().split()))
if a % b == 0 and n == 0:
	print(1)
	exit(0)
a %= b
ans = -1
for i in range(0, 1000):
	a *= 10
	if int(a / b) % 10 == n:
		ans = i + 1
		break
	if a > b:
		a -= int(a / b) * b
print(ans)


(a, b, c) = map(int, input().split())
i = 0
while i < 100000:
	i += 1
	a = 10 * a
	k = int(a / b)
	if c == k:
		print(i)
		exit(0)
	a = a % b
print(-1)


def divide(x, y):
	a = []
	integer = []
	decimal = []
	while x > 0:
		a.append(x % 10)
		x = x // 10
	a.reverse()
	[a.append(0) for x in range(y)]
	k = 0
	for (i, n) in enumerate(a):
		k = k * 10 + a[i]
		p = 0
		while p <= k:
			p += y
		p -= y
		k = k - p
		if i <= len(a) - y - 1:
			integer.append(p // y)
		else:
			decimal.append(p // y)
	return (integer, decimal)
(a, b, c) = (int(x) for x in input().split())
(integer, decimal) = divide(a, b)
if c in decimal:
	print(decimal.index(c) + 1)
else:
	print(-1)


def hdiv(dividend, divisor, precision=0):
	a = dividend
	b = divisor
	if abs(a + b) == abs(a) + abs(b):
		flag = 1
	else:
		flag = -1
	a = abs(a)
	b = abs(b)
	quotient = a // b
	remainder = a % b
	if remainder == 0:
		return quotient
	ans = str(quotient) + '.'
	i = 0
	while i < precision:
		a = remainder * 10
		quotient = a // b
		remainder = a % b
		ans += str(quotient)
		if remainder == 0:
			break
		i += 1
	if precision == 0:
		ans = ans.replace('.', '')
	if flag == -1:
		ans = '-' + ans
	return ans
(a, b, c) = map(int, input().split())
s = str(hdiv(a, b, 100000)).split('.')[-1:]
index = 0
flag = False
for item in s[0]:
	index += 1
	if str(item) == str(int(c)):
		print(index)
		flag = True
		break
if flag is False and index < 9 and (int(c) == 0):
	print(index + 1)
	flag = True
if flag is False:
	print(-1)


(a, b, c) = map(int, input().split())
s = ''
while len(s) < 1000:
	a *= 10
	s += str(a // b)
	a %= b
if s.find(str(c)) == -1:
	print('-1')
else:
	print(s.find(str(c)) + 1)


def main():
	was = [False] * 1000005
	(a, b, c) = map(int, input().split())
	p = 0
	while True:
		p += 1
		a *= 10
		if was[a]:
			break
		was[a] = True
		cur = int(a / b)
		a %= b
		if cur == c:
			print(p)
			return
	print(-1)
main()


def Decimals(a, b):
	denom = list()
	while a != 0 and a not in denom:
		denom.append(a)
		a *= 10
		yield (a // b)
		a = a % b
	if a == 0:
		yield 0

def main():
	(a, b, c) = map(int, input().strip().split())
	for (i, n) in enumerate(Decimals(a, b)):
		if n == c:
			print(i + 1)
			return
	else:
		print(-1)
main()


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


(a, b, c) = list(map(int, input().split()))
rem = a % b
lf = {}
lf[rem] = True
div = rem * 10 // b
rem = rem * 10 % b
pdiv = div
if div != c:
	pos = 2
	output = -1
	while True:
		divn = rem * 10 // b
		if c == divn:
			output = pos
			break
		if lf.get(rem, False):
			break
		lf[rem] = True
		rem = rem * 10 % b
		pos += 1
	print(output)
else:
	print(1)


x = input().split()
a = int(x[0])
b = int(x[1])
c = int(x[2])
y = a * 10 ** 10000 // b
z = a // b
s = str(y)
ss = str(z)
dif = 10000 - len(s)
for i in range(dif):
	s = '0' + s
if ss == '0':
	ss = ''
for i in range(0, len(s) - len(ss)):
	if s[i + len(ss)] == str(c):
		print(i + 1)
		exit(0)
print('-1')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import heapq
from collections import Counter
from bisect import bisect_right

def sum(x, c):
	ind = x
	val = 0
	while ind > 0:
		val += c[ind]
		ind -= ind & -1 * ind
	return val

def update(ind, x, b):
	i = ind
	while i <= n:
		b[i] += x
		i += i & -1 * i
import bisect
import math
(n, k, c) = map(int, input().split())
n = n % k
if n == 0:
	print(-1)
	exit()
for i in range(10 ** 5):
	n = n * 10
	if n // k == c:
		print(i + 1)
		break
	n = n % k
else:
	print(-1)


from decimal import *
getcontext().prec = 2048
getcontext().rounding = ROUND_DOWN
(a, b, c) = [int(x) for x in input().strip().split(' ')]
if b == 0:
	print(-1)
else:
	strNum = str(Decimal(a) / Decimal(b))
	strNum = [int(x) for x in strNum[strNum.index('.') + 1:]]
	try:
		print(strNum.index(c) + 1)
	except:
		if c == 0 and len(strNum) != 2048:
			print(len(strNum) + 1)
		else:
			print(-1)


from decimal import *
(a, b, c) = input().split()
a1 = int(a)
b1 = int(b)
c11 = int(c)
getcontext().prec = b1
c1 = Decimal(a1) / Decimal(b1)
c2 = str(c1)
q1 = b1 % 2
q2 = b1 % 5
if q1 == 0 or q2 == 0:
	c2 = c2 + '0'
length = len(c2)
b = 0
res = 0
j = 0
for i in range(length):
	if c2[i] == '.':
		b = 1
		j = 0
	elif c2[i] == c and b == 1:
		if c != 0 and j < b1:
			print(j)
			res = 1
			break
		elif c11 == 0:
			print(j)
			res = 1
			break
	j += 1
if res == 0:
	print(-1)


import sys

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

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

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

def listinput():
	return list(map(int, input().split()))
(a, b, pos) = minput()
for i in range(b):
	a *= 10
	c = a // b
	a = a % b
	if c == pos:
		print(i + 1)
		exit()
print('-1')


(a, b, c) = map(int, input().split())
a = a % b
res = '.'
if a > 0:
	l = {}
	while a and a not in l:
		l[a] = len(res)
		a *= 10
		res += str(a // b)
		a %= b
	if a in l:
		print(res.find(str(c)))
	else:
		res += '0'
		print(res.find(str(c)))
elif c == 0:
	print(1)
else:
	print(0)


import sys, math, io, os, time, itertools, collections
mod = 10 ** 9 + 7
sys.setrecursionlimit(10000)
i = sys.stdin.readline
p = sys.stdout.write
global start, end

def isin(l, x):
	left = 0
	right = len(l) - 1
	if x < l[0]:
		return -1
	while left <= right:
		mid = left + (right - left) // 2
		if l[mid] == x:
			return mid
		elif l[mid] < x:
			ans = mid
			left = mid + 1
		else:
			right = mid - 1
	return ans

def ispal(l):
	n = len(l)
	for i in range(n // 2 + 1):
		if l[i] != l[n - i - 1]:
			return False
	return True

def ccarray(l):
	d = {l[k]: k for k in range(len(l))}
	m = sorted(d)
	return [d[m[k]] for k in range(len(l))]

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

def sieve(n):
	prime = [True for k in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for k in range(p * p, n + 1, p):
				prime[k] = False
		p += 1

def main():
	(a, b, c) = [int(k) for k in i().split()]
	for k in range(b + 1):
		num = a % b * 10
		digit = num // b
		if digit == c:
			p(str(k + 1) + '\n')
			break
		a = num
	else:
		p('-1\n')
t = 1
start = time.perf_counter()
for _ in range(t):
	main()
end = time.perf_counter()


(a, b, c) = map(int, input().split())
from decimal import *
getcontext().prec = 1000
s = str(Decimal(a) / Decimal(b))
if len(s) > 1000:
	s = s[:len(s) - 1]
else:
	s += '0'
index = 0
for i in s:
	if i == '.':
		break
	index += 1
c = str(c)
ans = 0
flag = False
l = len(s)
for i in range(index + 1, l):
	ans += 1
	if s[i] == c:
		flag = True
		break
if flag:
	print(ans)
else:
	print(-1)


(a, b, c) = map(int, input().split())
ans = -1
for i in range(1, 1000):
	a = a * 10
	temp = a // b
	if temp % 10 == c:
		ans = i
		break
print(ans)


def divide(a, b):
	assert b > 0
	integer = a // b
	remainder = a % b
	seen = {remainder: 0}
	digits = []
	while True:
		remainder *= 10
		digits.append(remainder // b)
		remainder = remainder % b
		if remainder in seen:
			where = seen[remainder]
			return (integer, digits[:where], digits[where:])
		else:
			seen[remainder] = len(digits)
(x, y, z) = map(int, input().split())
(i, f, r) = divide(x, y)
re = ''.join(map(str, r))
fl = ''.join(map(str, f))
st = ''
for i in fl:
	if i.isdigit():
		st += i
for i in re:
	if i.isdigit():
		st += i
chk = str(z)
ans = st.find(chk)
if ans >= 0:
	ans += 1
print(ans)


def convert(numerator, denominator):
	integer_part = str(numerator // denominator)
	ans = ''
	l = dict()
	i = 0
	numerator = numerator % denominator
	l[numerator] = i
	i += 1
	if numerator == 0:
		return integer_part
	while True:
		if numerator == 0:
			return '{}.{}'.format(integer_part, ans)
		(digit, numerator) = divmod(numerator * 10, denominator)
		ans += str(digit)
		if numerator not in l:
			l[numerator] = i
			i += 1
		else:
			return '{}.{}({})'.format(integer_part, ans[:l[numerator]], ans[l[numerator]:])

def main():
	(a, b, c) = map(int, input().split())
	k = convert(a, b)
	s = str(k)
	s = s[s.find('.') + 1:]
	period = s.find('(')
	if period >= 0:
		s = s[:period] + s[period + 1:s.find(')')]
	else:
		s = s + '0'
	ans = s.find(str(c))
	if ans >= 0:
		print(ans + 1)
	else:
		print(-1)
main()


(a, b, c) = map(int, input().split())
for i in range(b):
	div = a * 10 // b
	if div == c:
		print(i + 1)
		exit()
	else:
		a = a * 10 - div * b
print(-1)


from decimal import *
N = 100100
getcontext().prec = N
(a, b, c) = (int(x) for x in input().split())
f = Decimal(a) / Decimal(b)
f = f.quantize(Decimal(10) ** (-N))
s = str(f)[2:-10]
p = s.find(str(c))
if p >= 0:
	p += 1
print(p)


(a, b, c) = [int(i) for i in input().split()]
fr = [0] * 5000001
cr = a
ans = []
while cr < b:
	cr *= 10
	ans.append(0)
ans = ans[1:]
while True:
	fr[cr] = 1
	v = cr // b
	ans.append(v)
	cr = cr - v * b
	cr *= 10
	if fr[cr]:
		break
if c not in ans:
	print(-1)
else:
	print(ans.index(c) + 1)


(a, b, c) = map(int, input().split())
cc = 1
for i in range(100000):
	cc += 1
	a *= 10
	if a // b == c:
		print(cc - 1)
		exit()
	a %= b
print(-1)


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
l = []
rem = a
while rem * 10 // b == 0:
	ans = rem * 10 // b
	l.append(ans)
	rem = rem * 10 % b
nz = rem * 10 // b
l.append(nz)
rem = rem * 10 % b
for i in range(1001):
	ans = rem * 10 // b
	rem = rem * 10 % b
	l.append(ans)
j = 1
find = False
for i in l:
	if c == i:
		print(j)
		find = True
		break
	j += 1
if not find:
	print(-1)


from decimal import *
(a, b, c) = map(int, input().split())

def f(z, c):
	l = len(z)
	for i in range(1, l):
		if z[i] == c:
			print(i)
			return
if c == 0:
	z = str(a / b)[1:]
	getcontext().prec = 600
	zz = str(Decimal(a) / Decimal(b))[1:]
	if '0' in zz:
		f(zz, '0')
	elif len(zz) < 500:
		print(len(z))
	else:
		print(-1)
	exit()
getcontext().prec = 600
z = str(Decimal(a) / Decimal(b))
c = str(c)
if a % b:
	z = str(z)[1:600]
	if c in z:
		f(z, c)
	else:
		print(-1)
elif c == 0:
	print(1)
else:
	print(-1)


split_strings = input().split()
[a, b, c] = map(lambda x: int(x), split_strings)
seen_so_far = set()
remainder = a % b * 10
position = 1
while True:
	digit = remainder // b
	remainder %= b
	if digit == c:
		print(position)
		exit(0)
	if remainder in seen_so_far:
		print(-1)
		exit(0)
	seen_so_far.add(remainder)
	remainder *= 10
	position += 1


(a, b, c) = map(int, input().split())
d = set()
ans = -1
cnt = 1
while True:
	a *= 10
	g = a // b
	if g == c:
		ans = cnt
		break
	cnt += 1
	a %= b
	if a in d:
		break
	d.add(a)
print(ans)


(a, b, c) = map(int, input().split())
a = a % b
ans = []
for _ in range(10 ** 5):
	a = a * 10
	ans.append(a // b)
	a = a % b
if c in ans:
	print(ans.index(c) + 1)
else:
	print(-1)


def isPeriodic(y):
	val = y
	while True:
		if val % 5 == 0:
			val = val / 5
		elif val % 2 == 0:
			val = val / 2
		else:
			return True
		if val == 1:
			return False

def largoDenominador(y):
	val = y
	i = 1
	while val != 0:
		val = val // 10
		i += 1
	return i

def PF(x, y, z):
	i = 1
	valor = 10
	periodico = isPeriodic(y)
	size = largoDenominador(y)
	while 1:
		fraction = x * valor // y
		modulo = fraction % 10 // 1
		if modulo == z:
			return i
		elif periodico == False and size == i:
			return -1
		if periodico and i > 10000:
			return -1
		valor *= 10
		i += 1
(aux1, aux2, aux3) = input().split(' ')
val1 = int(aux1)
val2 = int(aux2)
val3 = int(aux3)
print(PF(val1, val2, val3))