n=int(input()) k=1 while 1: if pow(10,k,n)==1: print(k) exit() k+=1