odd = int(input())
for n in range(1, 8 + 1): # factorial(8)=40320, if not found until 8, then forget it
times = math.factorial(n)
for d in range(1, 9 + 1): # Check every possible number
if int(str(d) * times) % odd != 0:
break
else:
print(n) # If n is greater than or equal to this value, it must be divisible by odd
break
else:
print(None)