k = gets.chomp.to_i

#if k % 2 == 0 || k % 5 == 0
#  puts -1
#  exit
#end
count = 0
i = 0
while true do
  i = i * 10 + 1
  i %= k
  count += 1
  if i == 0
    break
  elsif count > 10 ** 6
    puts -1
    exit
  end
end

puts count
