k = gets.to_i
d = k % 10
if d % 2 == 0 || d == 5
  puts -1
  exit
end

table = {
  1 => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
  3 => [0, 7, 4, 1, 8, 5, 2, 9, 6, 3],
  7 => [0, 3, 6, 9, 2, 5, 8, 1, 4, 7],
  9 => [0, 9, 8, 7, 6, 5, 4, 3, 2, 1],
}

num = 7
cnt = 1
i = 0
while true do
  m = table[d][num % 10]
  p = k * m
  while num < p do
    num += 7 * 10 ** (cnt - i)
    cnt += 1
  end
  num -= p
  raise 'oops' unless num % 10 == 0
  num /= 10
  break if num == 0
  i += 1
end
puts cnt
