N = int(input())

now = 0
ans = 0

while True:
	now = (now * 10 + 9)% N
	ans += 1
	if now == 0:
		print(ans)
		break