N=int(input()) t=10 if (t-1)%N==0: print(1) exit() c=1 while True: if t==1: print(c) exit() t=(t*10)%N c+=1