# 백준#4375 1
# https://www.acmicpc.net/problem/4375
while True:
try:
n = int(input())
except:
break
i = 1
while True:
num = num * 10 + 1
num %= n
if num == 0:
print(i)
break
i += 1
# 백준#4375 1
# https://www.acmicpc.net/problem/4375
while True:
try:
n = int(input())
except:
break
i = 1
num = 0
while True:
target_num = int('1'*i)
# print(target_num)
# num = num * 10 + 1
# num %= n
if target_num % n == 0:
print(i)
break
i += 1