last_num = 7
num = gets.to_i
 
while true
  if last_num  % num == 0
    puts last_num.to_s.length
    break
  elsif num % 2 == 0 || last_num.to_s.length < 10**6
    puts '-1'
    break
  else
    last_num = (last_num.to_s + "7").to_i
  end
end