k = gets.chomp.to_i

 
if k % 2 == 0 || k % 5 == 0
  puts -1
  exit
end
 
count = 0
i = 0
k /= 7 if k % 7 == 0
while true do
  i = i * 10 + 1
  i %= k
  count += 1
  if i == 0
    break
  end
end
 
puts count