k = gets.chomp.to_i

arr = Array.new(k+1,0)

ngo = 7
(k+1).times do |i|
	arr[i] = ngo % k
	ngo = (ngo * 10 + 7) % k
	#puts i if i%10000 == 0
end

ngo = arr.index{|a| a == 0}  
puts ngo != nil ? ngo + 1 : -1