n = int(input()) k = 1 while True: x = 10 ** k - 1 if x % n == 0: print(k) break k += 1