K = gets.to_i
７ = [
	[],
	[7,6,5,4,3,2,1,0,9,8],
	[],
	[9,2,5,8,1,4,7,0,3,6],
	[],
	[],
	[],
	[1,8,5,2,9,6,3,0,7,4],
	[],
	[3,4,5,6,7,8,9,0,1,2]
][K%10].map!{|_|_*K}
if ７.empty?
	p(-1)
	exit
end

n = 0
k = ７[0]
while 0<k
	n += 1
	k += ７[k%10]
	k /= 10
end
p n
