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],
	[],
	[]
][K%10]
if ７.empty?
	p(-1)
	exit
end

n = 0
k = K*７[0]
z = 0
while 0<k
	k += K*７[z] if 7 != z = k%10
	n += 1
	k /= 10
end
p n
