k=gets.to_i
rems=Array.new(k,false)
count=0
rem=0
if k==1
  puts 1
else
  loop do
    rem = (rem*10+7)%k
    count += 1
    if rems[rem]
      puts -1
      break
    elsif rem==0
      puts count
      break
    end
    rems[rem]=true
  end
end