n=int(input()) k=1 r=9 while r%n!=0: k+=1 r=(r*10+9)%n print(k)