from sys import stdin def solve(n): m,r = 1,1 while m%n!=0: m,r = m*10+1,r+1 return r def main(): for l in stdin.readlines(): n = int(l) print(solve(n)) main()