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