R=range N=int(input()) for i in range(1,10**8): if(10**i-1)%N<1:exit(print(i))