N = int(input()) K = 1 remainder = 9 % N while remainder != 0: K += 1 remainder = (remainder * 10 + 9) % N print(K)