K = gets.to_i

k = K
k = K / 7 if K % 7 == 0
rc = Array.new(k)
wk, x, ans = 1, 0, -1
while true do
  wk *= 10
  x += 1
  mod = wk % k
  if mod == 0 then
    break
  elsif rc[mod].nil? then
    rc[mod] = x
  else
    ans = x - rc[mod]
    break
  end
  wk = mod
end

puts ans
