arr = [7]
num = gets.to_i

while 1
  if arr.last % num == 0
    puts arr.last.to_s.length
    break
  elsif num % 2 == 0 || arr.last.to_s.length > 10**6
    puts '-1'
    break
  else
    arr << (arr.last.to_s + "7").to_i
  end
end