K = gets.to_i
a = K.to_s.length
ans = -1

if K%2 == 0 || K%5 == 0
  puts -1
else
  while (ans == -1) do 
    x = 7*(10**a-1)/9
      if x%K == 0
       ans = a
      end
    a += 1
  end
puts a
end

    
    