N = int(input()) if N==1 or N==3 or N==9: print(1) else: n = 1 cnt = 1 for k in range(2,N+1): n = (n*10)%N cnt += n if cnt%N==0: print(k) break