k=gets.to_i
if k%2==0||k%5==0
  puts -1
  exit
end
#if k%7==0
#  n=k.to_s.size-1
#else
#  n=(k*7).to_s.size-1
#end
n=k
loop do
  num=("7"*n).to_i
#  print "#{n}: 余:#{num%k}"
  if num%k==0
    puts ""
    p n
    exit
  end
#  puts " false"
  n-=1
end

