k = gets.to_i
hash = Hash.new(0)
an = 0
i = 0
flg = true
while flg
  i += 1
  an = an * 10 + 7
  an %= k
  if an == 0
    flg = false
  end
  if hash[an] == 0
    hash[an] = 1
  else
    i = -1
    flg = false
  end
end
puts i