K = gets.chomp.to_i

a = 1

unless [1, 3, 7, 9].include?(K % 10)
  puts -1
  exit
end

#p K
tmp = 0
ichi = K % 10
while true
  #p "tmp: #{tmp}"
  tmp_mod_10 = tmp % 10
  kakeru = (0..9).find{ |n| (n * ichi % 10) == if (tmp_mod_10 <= 7) then (7 - tmp_mod_10) else (17 - tmp_mod_10) end }
  #p "kakeru: #{kakeru}"
  kaketa = K * kakeru
  tmp += kaketa
  tmp /= 10
  break if tmp.to_s.each_char.all?{ |c| c == "7" }
  a += 1
  #p a
end

puts a
