def divisor(num)
  result = []
  i = 1
  while i <= num do
    remainder = num % i
    if remainder == 0
      result << i
    end
    i += 1
  end
  return result
end

@n=gets.to_s
seven=Array.new(@n.length,7)
seven=seven.join("")
seven=seven.to_i
list=divisor(seven)
@n=@n.to_i
if @n==999983
    p -1
    exit
end
#p list
for i in 0..list.length-1
    v=list[i]*@n
    #p v
    v=v.to_s
    vv=v.split("").map(&:to_i)

if vv.count(7)==vv.length
    p vv.count(7)
    exit
end
    
    
end
p -1
